Part Number Hot Search : 
1106AG2 CY621 SR5200 SMAJ58A LN473YPX 00020 1N3288A 0997002
Product Description
Full Text Search
 

To Download UPD17012GF-053-3BE Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  data sheet ? 1994, 2000 the information in this document is subject to change without notice. before using this document, please confirm that this is the latest version. not all devices/types available in every country. please check with local nec representative for availability and additional information. mos integrated circuit pd17012, 17p012 4-bit single-chip microcontrollers with digital tuning system hardware description the pd17012 is a 4-bit single-chip cmos microcontroller equipped with hardware for digital tuning systems. the pd17p012 is a version of the pd17012 with one-time prom instead of mask rom. the user can write programs to the pd17p012 once, and it is ideal for experimental production of the pd17012 during system design or small-scale production. this series employs a 17k architecture cpu that can directly manipulate the data memory, execute various operations, and control the peripheral hardware with a single instruction. all the instructions are one-word 16-bit instructions. besides various i/o ports, an lcd controller/driver, a/d converter, d/a converter (pwm output), and beep output, this microcontroller has a prescaler that can operate at up to 250 mhz, a pll frequency synthesizer, and frequency counter for digital tuning systems. this series therefore ideal for configuring a high-performance, multi- functional digital tuning system on a single chip. features 17k architecture: general-purpose register method program memory (rom) pd17012: mask rom 8 kb (4,096 16 bits) pd17p012: one-time prom 8 kb (4,096 16 bits) general-purpose data memory (ram) 316 4 bits instruction execution time 4.44 s (with 4.5 mhz crystal resonator) decimal operation table reference hardware for pll frequency synthesizer dual modulus prescaler (250 mhz max.), programmable divider, phase comparator, charge pump various peripheral hardware general-purpose i/o ports, lcd controller/driver, serial interface, a/d converter, d/a converter (pwm output), beep output, frequency counter interrupts external: 1 internal: 3 power-on-reset, reset by ce pin, and power failure detector power-saving cmos supply voltage: v dd = 5 v 10% the mark shows major revised points. document no. u10101ej4v0ds00 (4th edition) date published august 2001 n cp(k) printed in japan
pd17012, 17p012 2 data sheet u10101ej4v0ds ordering information part number package pd17012gf- -3be 64-pin plastic qfp (14 20) pd17012gc- -8bt 80-pin plastic qfp (14 14) pd17p012gf-3be 64-pin plastic qfp (14 20) pd17p012gc-8bt 80-pin plastic qfp (14 14) remark indicates the rom code suffix. overview of functions item pd17012 pd17p012 program memory (rom) 8 kb (4,096 16 bits) (mask rom) 8 kb (4,096 16 bits) (one-time prom) table reference area: 4,096 16 bits general-purpose data memory (ram) 316 4 bits register file 33 4 bits (control register) port register 12 4 bits (functions alternately as lcd segment register) instruction execution time 4.44 s (with 4.5 mhz crystal resonator) stack levels address stack: 5 levels (stack operation enabled) interrupt stack: 2 levels (stack operation disabled) general-purpose ports i/o ports: 14 pins input ports: 8 pins output ports: 8 pins (+20: lcd segment pin) beep output 2 pins (frequency can be set individually) selectable frequency (200 hz, 1 khz, 3 khz, 9 khz) lcd controller/driver 20 segments, 3 commons 1/3 duty, 1/2 bias, frame frequency: 167 hz, drive voltage: v dd , segment pins also used as key source pins: 16 all 20 pins can be used as output port pins (4 pins can be set in output mode individually and the rest are set at once) serial interface 1 channel 3-wire (serial i/o) d/a converter 8 bits 2 channels (pwm output) a/d converter 6 bits 2 channels (successive approximation method by software) interrupts 4 (maskable) external: 1 (int pin) internal: 3 (timer 2, serial interface) timer 3 channels 12-bit timer (10, 50 s) basic timer 0 (1, 5, 100, 250 ms) basic timer 1 (1, 5, 100, 250 ms) reset power-on reset (on power application) reset by ce pin (ce pin low level high level) power failure detection function
pd17012, 17p012 3 data sheet u10101ej4v0ds item pd17012 pd17p012 pll frequency division mode two types synthesizer direct division mode (vcol pin: 20 mhz max.) pulse swallow mode (vcol pin: 30 mhz max.) (vcoh pin: 250 mhz max.) reference 12 programmable frequencies frequency 1, 1.25, 2.5, 3, 5, 6.25, 9, 10, 12.5, 25, 50, 100 khz charge pump error-out outputs: 1 phase comparator unlock detection by program frequency counter frequency measurement p1b 3 /fmifc pin: in fmif mode 5 to 15 mhz in amif mode 0.3 to 1 mhz p1b 2 /amifc pin: 0.3 to 1 mhz external gate width measurement p0b 3 /fcg 1 , p0b 2 /fcg 0 pins supply voltage v dd = 5 v 10% package 64-pin plastic qfp (14 20) 80-pin plastic qfp (14 14)
pd17012, 17p012 4 data sheet u10101ej4v0ds pin configuration (top view) (1) pd17012 64-pin plastic qfp (14 20) pd17012gf- -3be p1a 1 p1a 0 eo v dd1 vcol vcoh ce v dd2 p0a 2 /sck 1 p0a 1 /so 1 p0a 0 /si 1 p1b 3 /fmifc p1b 2 /amifc p1b 1 /adc 1 p1b 0 /adc 0 p0b 3 /fcg 1 p0b 2 /fcg 0 p0b 1 /beep 1 p0b 0 /beep 0 lcd 6 /ks 6 /pya 6 lcd 7 /ks 7 /pya 7 lcd 8 /ks 8 /pya 8 lcd 9 /ks 9 /pya 9 lcd 10 /ks 10 /pya 10 lcd 11 /ks 11 /pya 11 lcd 12 /ks 12 /pya 12 lcd 13 /ks 13 /pya 13 lcd 14 /ks 14 /pya 14 lcd 15 /ks 15 /pya 15 lcd 16 /p2e 0 lcd 17 /p2f 0 lcd 18 /p2g 0 lcd 19 /p2h 0 com 0 com 1 com 2 p1d 0 p1d 1 int p1a 2 p0d 0 /k 0 p0d 1 /k 1 p0d 2 /k 2 p0d 3 /k 3 gnd lcd 0 /ks 0 /pya 0 lcd 1 /ks 1 /pya 1 lcd 2 /ks 2 /pya 2 lcd 3 /ks 3 /pya 3 lcd 4 /ks 4 /pya 4 lcd 5 /ks 5 /pya 5 p1c 3 p1c 2 p1c 1 p1c 0 x out x in gnd p0c 3 p0c 2 p0c 1 /pwm 1 p0c 0 /pwm 0 p1d 3 p1d 2 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 64 63 62 61 60 59 58 57 56 55 54 53 52 20 21 22 23 24 25 26 27 28 29 30 31 32
pd17012, 17p012 5 data sheet u10101ej4v0ds 80-pin plastic qfp (14 14) pd17012gc- -8bt p1a 0 eo v dd1 nc vcol vcoh ce v dd2 v dd2 p0a 2 /sck 1 p0a 1 /so 1 p0a 0 /si 1 p1b 3 /fmifc p1b 2 /amifc nc p1b 1 /adc 1 p1b 0 /adc 0 p0b 3 /fcg 1 p0b 2 /fcg 0 p0b 1 /beep 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 lcd 7 /ks 7 /pya 7 lcd 8 /ks 8 /pya 8 lcd 9 /ks 9 /pya 9 lcd 10 /ks 10 /pya 10 lcd 11 /ks 11 /pya 11 lcd 12 /ks 12 /pya 12 nc lcd 13 /ks 13 /pya 13 lcd 14 /ks 14 /pya 14 nc lcd 15 /ks 15 /pya 15 lcd 16 /p2e 0 lcd 17 /p2f 0 lcd 18 /p2g 0 lcd 19 /p2h 0 com 0 com 1 nc com 2 p1d 0 p1a 1 nc int p1a 2 p0d 0 /k 0 p0d 1 /k 1 p0d 2 /k 2 p0d 3 /k 3 nc gnd nc gnd nc lcd 0 /ks 0 /pya 0 lcd 1 /ks 1 /pya 1 lcd 2 /ks 2 /pya 2 lcd 3 /ks 3 /pya 3 lcd 4 /ks 4 /pya 4 lcd 5 /ks 5 /pya 5 lcd 6 /ks 6 /pya 6 p0b 0 /beep 0 p1c 3 nc p1c 2 p1c 1 p1c 0 x out x in nc gnd gnd nc poc 3 poc 2 poc 1 /pwm 1 nc poc 0 /pwm 0 p1d 3 p1d 2 p1d 1 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 caution pin 4 can also be used as the v dd1 pin. use pin 4 as the v dd1 pin when using the pd17012 and pd17p012 on the same board.
pd17012, 17p012 6 data sheet u10101ej4v0ds (2) pd17p012 64-pin plastic qfp (14 20) pd17p012gf-3be (a) normal operation mode p1a 1 p1a 0 eo v dd1 vcol vcoh ce v dd2 p0a 2 /sck 1 p0a 1 /so 1 p0a 0 /si 1 p1b 3 /fmifc p1b 2 /amifc p1b 1 /adc 1 p1b 0 /adc 0 p0b 3 /fcg 1 p0b 2 /fcg 0 p0b 1 /beep 1 p0b 0 /beep 0 lcd 6 /ks 6 /pya 6 lcd 7 /ks 7 /pya 7 lcd 8 /ks 8 /pya 8 lcd 9 /ks 9 /pya 9 lcd 10 /ks 10 /pya 10 lcd 11 /ks 11 /pya 11 lcd 12 /ks 12 /pya 12 lcd 13 /ks 13 /pya 13 lcd 14 /ks 14 /pya 14 lcd 15 /ks 15 /pya 15 lcd 16 /p2e 0 lcd 17 /p2f 0 lcd 18 /p2g 0 lcd 19 /p2h 0 com 0 com 1 com 2 p1d 0 p1d 1 int p1a 2 p0d 0 /k 0 p0d 1 /k 1 p0d 2 /k 2 p0d 3 /k 3 gnd lcd 0 /ks 0 /pya 0 lcd 1 /ks 1 /pya 1 lcd 2 /ks 2 /pya 2 lcd 3 /ks 3 /pya 3 lcd 4 /ks 4 /pya 4 lcd 5 /ks 5 /pya 5 p1c 3 p1c 2 p1c 1 p1c 0 x out x in gnd p0c 3 p0c 2 p0c 1 /pwm 1 p0c 0 /pwm 0 p1d 3 p1d 2 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 64 63 62 61 60 59 58 57 56 55 54 53 52 20 21 22 23 24 25 26 27 28 29 30 31 32
pd17012, 17p012 7 data sheet u10101ej4v0ds (b) prom programming mode caution the items in parentheses indicates the processing of pins not used in the prom programming mode. l: independently connect to gnd via a resistor open: leave open. v dd1 (open) v pp (l) md 0 md 1 md 2 md 3 gnd d 0 d 1 d 2 d 3 (open) clk gnd 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 64 63 62 61 60 59 58 57 56 55 54 53 52 20 21 22 23 24 25 26 27 28 29 30 31 32 v dd2 d 4 d 5 d 6 d 7 (l) (l) (l) (l) (l) (l) (open) (open)
pd17012, 17p012 8 data sheet u10101ej4v0ds 80-pin plastic qfp (14 x 14) pd17p012gc-8bt (a) normal operation mode p1a 0 eo v dd1 v dd1 vcol vcoh ce v dd2 v dd2 p0a 2 /sck 1 p0a 1 /so 1 p0a 0 /si 1 p1b 3 /fmifc p1b 2 /amifc nc p1b 1 /adc 1 p1b 0 /adc 0 p0b 3 /fcg 1 p0b 2 /fcg 0 p0b 1 /beep 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 lcd 7 /ks 7 /pya 7 lcd 8 /ks 8 /pya 8 lcd 9 /ks 9 /pya 9 lcd 10 /ks 10 /pya 10 lcd 11 /ks 11 /pya 11 lcd 12 /ks 12 /pya 12 nc lcd 13 /ks 13 /pya 13 lcd 14 /ks 14 /pya 14 nc lcd 15 /ks 15 /pya 15 lcd 16 /p2e 0 lcd 17 /p2f 0 lcd 18 /p2g 0 lcd 19 /p2h 0 com 0 com 1 nc com 2 p1d 0 p1a 1 nc int p1a 2 p0d 0 /k 0 p0d 1 /k 1 p0d 2 /k 2 p0d 3 /k 3 nc gnd nc gnd nc lcd 0 /ks 0 /pya 0 lcd 1 /ks 1 /pya 1 lcd 2 /ks 2 /pya 2 lcd 3 /ks 3 /pya 3 lcd 4 /ks 4 /pya 4 lcd 5 /ks 5 /pya 5 lcd 6 /ks 6 /pya 6 p0b 0 /beep 0 p1c 3 nc p1c 2 p1c 1 p1c 0 x out x in nc gnd gnd nc poc 3 poc 2 poc 1 /pwm 1 nc poc 0 /pwm 0 p1d 3 p1d 2 p1d 1 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
pd17012, 17p012 9 data sheet u10101ej4v0ds (b) prom programming mode caution the items in parentheses indicates the processing of pins not used in the prom programming mode. l: independently connect to gnd via a resistor open: leave open. v dd1 v dd1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 nc (l) nc v pp (l) md 0 md 1 md 2 md 3 nc gnd nc gnd nc (l) d 0 nc d 1 d 2 d 3 (open) clk nc gnd gnd nc 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 nc (open) nc nc (open) (l) d 4 d 5 nc d 6 d 7 v dd2 v dd2 (l) (l) (l) (l) (open) (open) (open) (open) (l) (open)
pd17012, 17p012 10 data sheet u10101ej4v0ds pin identification adc 0 , adc 1 : a/d converter input amifc: am intermediate frequency counter input beep 0 , beep 1 : beep output ce: chip enable input clk: address update clock input com 0 to com 2 : lcd common signal output d 0 to d 7 : data i/o eo: error out output fcg 0 , fcg 1 : external gate counter input fmifc: fm intermediate frequency counter input gnd: ground int: external interrupt input k 0 to k 3 : key source signal input ks 0 to ks 15 : key source signal output lcd 0 to lcd 19 : lcd segment signal output nc: no connection md 0 to md 3 : operation mode selection p0a 0 to p0a 2 : port 0a p0b 0 to p0b 3 : port 0b p0c 0 to p0c 3 : port 0c p0d 0 to p0d 3 : port 0d p1a 0 to p1a 2 : port 1a p1b 0 to p1b 3 : port 1b p1c 0 to p1c 3 : port 1c p2e 0 : port 2e p2f 0 : port 2f p2g 0 : port 2g p2h 0 : port 2h pwm 0 , pwm 1 : d/a converter output pya 0 to pya 15 : port ya sck 1 : serial clock i/o si 1 : serial data input so 1 : serial data output vcoh: local oscillation high input vcol: local oscillation low input v dd1 , v dd2 : power supply v pp : program voltage application x in , x out : crystal resonator connection
pd17012, 17p012 11 data sheet u10101ej4v0ds block diagram (1) pd17012 3 p0a 0 to p0a 2 4 p0b 0 to p0b 3 4 p0d 0 /k 0 to p0d 3 /k 3 3 p1a 0 to p1a 2 4 p1d 0 to p1d 3 4 p0c 0 to p0c 3 16 pya 0 to pya 15 4 p1b 0 to p1b 3 4 p1c 0 to p1c 3 p2e 0 p2f 0 p2g 0 p2h 0 port pll osc vcoh vcol eo x in x out cpu peripheral rf system register ram 16 4 bits alu instruction decoder mask rom 4,096 16 bits program counter stack 5 12 bits fcg 0 /p0b 2 d/a converter pwm 1 /p0c 1 pwm 0 /p0c 0 beep 1 /p0b 1 beep 0 /p0b 0 basic timer 1 basic timer 0 12-bit timer a/d converter adc 1 /p1b 1 adc 0 /p1b 0 com 0 com 1 com 2 lcd 0 /pya 0 /ks 0 to lcd 15 /pya 15 /ks 15 lcd 16 /p2e 0 lcd 17 /p2f 0 lcd 18 /p2g 0 lcd 19 /p2h 0 frequency counter lcd controller/ driver fmifc/p1b 3 serial interface sck 1 /p0a 2 si 1 /p0a 0 beep so 1 /p0a 1 interrupt control int reset v dd1 ce v dd2 gnd fcg 1 /p0b 3 amifc/p1b 2
pd17012, 17p012 12 data sheet u10101ej4v0ds (2) pd17p012 remark the items in parentheses indicate the pins when used in the prom programming mode. 3 p0a 0 to p0a 2 4 p0b 0 to p0b 3 4 p0d 0 to p0d 3 (md 0 to md 3 ) 3 p1a 0 to p1a 2 4 p1d 0 to p1d 3 4 p0c 0 to p0c 3 16 pya 0 to pya 15 4 p1b 0 to p1b 3 (d 7 to d 4 ) 4 p1c 0 to p1c 3 (d 3 to d 0 ) p2e 0 p2f 0 p2g 0 p2h 0 port pll osc vcoh vcol eo x in (clk) x out cpu peripheral rf system registers ram 16 4 bits alu instruction decoder one-time prom 4096 16 bits program counter stack 5 12 bits fcg 0 /p0b 2 d/a converter pwm 1 /p0c 1 pwm 0 /p0c 0 beep 1 /p0b 1 beep 0 /p0b 0 basic timer 1 basic timer 0 12-bit timer a/d converter adc 1 /p1b 1 adc 0 /p1b 0 com 0 com 1 com 2 lcd 0 /pya 0 /ks 0 to lcd 15 /pya 15 /ks 15 lcd 16 /p2e 0 lcd 17 /p2f 0 lcd 18 /p2g 0 lcd 19 /p2h 0 frequency counter lcd controller/ driver fmifc/p1b 3 serial interface sck 1 /p0a 2 si 1 /p0a 0 beep so 1 /p0a 1 interrupt control int (v pp ) reset v dd1 ce v dd2 gnd fcg 1 /p0b 3 amifc/p1b 2
pd17012, 17p012 13 data sheet u10101ej4v0ds contents 1. pin functions ................................................................................................................ ............ 18 1.1 pin function list ........................................................................................................... ..... 18 1.2 pin equivalent circuits ..................................................................................................... .21 1.3 recommended connection of unused pins ................................................................... 25 1.4 notes on using ce and int pins ...................................................................................... 26 2. program memory (rom) ........................................................................................................ 2 7 2.1 outline of program memory .............................................................................................. 27 2.2 program memory .............................................................................................................. .28 2.3 program counter ............................................................................................................. .. 28 2.4 program flow ................................................................................................................ ..... 29 3. address stack (ask) .......................................................................................................... .... 31 3.1 outline of address stack .................................................................................................. 31 3.2 address stack registers (asr) ........................................................................................ 31 3.3 stack pointer (sp) .......................................................................................................... .... 32 3.4 operation of address stack .............................................................................................. 33 3.5 notes on using address stack ......................................................................................... 33 4. data memory (ram) ............................................................................................................ ...... 34 4.1 outline of data memory .................................................................................................... 34 4.2 configuration and function of data memory .................................................................. 35 4.3 addressing of data memory ............................................................................................. 37 4.4 notes on using data memory ........................................................................................... 38 5. system register (sysreg) ................................................................................................... 39 5.1 outline of system register ............................................................................................... 39 5.2 system register list ........................................................................................................ .40 5.3 address register (ar) ....................................................................................................... 41 5.4 window register (wr) ...................................................................................................... 43 5.5 bank register (bank) ....................................................................................................... 4 4 5.6 index register (ix) and data memory row address pointer (mp: memory pointer) ... 45 5.7 general register pointer (rp) .......................................................................................... 47 5.8 program status word (psword) ..................................................................................... 49 5.9 notes on using system register ..................................................................................... 50 6. general register (gr) ........................................................................................................ .. 51 6.1 outline of general register .............................................................................................. 51 6.2 general register body ...................................................................................................... 5 1 6.3 address generation of general register by instructions .............................................. 52 6.4 notes on using general register ..................................................................................... 53 7. alu (arithmetic logic unit) block ........................................................................................... 5 4 7.1 outline of alu block ........................................................................................................ .54
pd17012, 17p012 14 data sheet u10101ej4v0ds 7.2 configuration and function of each block ..................................................................... 55 7.3 alu processing instruction list ...................................................................................... 55 7.4 notes on using alu .......................................................................................................... 59 8. register file (rf) ........................................................................................................... ......... 60 8.1 outline of register file .................................................................................................... .60 8.2 configuration and function of register file ................................................................... 61 8.3 register file manipulation instructions (?eek wr, rf and ?oke rf, wr? .............. 62 8.4 control registers ........................................................................................................... .... 62 8.5 notes on using register file ............................................................................................ 68 9. data buffer (dbf) ............................................................................................................ ........ 69 9.1 outline of data buffer ...................................................................................................... .. 69 9.2 data buffer ................................................................................................................. ........ 70 9.3 peripheral hardware and data buffer list ....................................................................... 71 9.4 notes on using data buffer .............................................................................................. 73 10. general-purpose ports ...................................................................................................... 7 4 10.1 configuration and classification of general-purpose ports ......................................... 74 10.2 functional outline of general-purpose ports ................................................................. 75 10.3 general-purpose i/o ports (p0a, p0b, p1a, and p1d) .................................................... 80 10.4 general-purpose input ports (p0d and p1b) .................................................................. 86 10.5 general-purpose output ports (p0c and p1c) ............................................................... 88 10.6 general-purpose output ports (p2e to p2h and pya) ................................................... 90 11. interrupts ................................................................................................................ ................ 97 11.1 outline of interrupt block ................................................................................................. .97 11.2 interrupt control block .................................................................................................... .. 99 11.3 interrupt stack register ................................................................................................... . 103 11.4 stack pointer, address stack register, program counter ............................................. 104 11.5 interrupt enable flip-flop (inte) ...................................................................................... 104 11.6 acknowledging interrupts ................................................................................................. 10 5 11.7 operations after acknowledging interrupt ..................................................................... 110 11.8 restoring from interrupt servicing routine .................................................................... 110 11.9 external (int pin) interrupt ............................................................................................... 111 11.10 internal interrupt ........................................................................................................ ........ 113 12. timer ....................................................................................................................... ..................... 114 12.1 general .................................................................................................................... ........... 114 12.2 basic timer 0 .............................................................................................................. ........ 115 12.3 basic timer 1 .............................................................................................................. ........ 128 12.4 12-bit timer ............................................................................................................... ......... 136 13. a/d converter (adc) ......................................................................................................... ...... 144 13.1 general .................................................................................................................... ........... 144 13.2 input selector block ....................................................................................................... ... 145 13.3 compare voltage generator block and compare block ................................................ 146 13.4 comparison timing chart ................................................................................................. 150 13.5 performance of a/d converter .......................................................................................... 150
pd17012, 17p012 15 data sheet u10101ej4v0ds 13.6 using a/d converter ........................................................................................................ .. 151 13.7 status on reset ............................................................................................................ ...... 156 14. d/a converter (dac) ....................................................................................................... ........ 157 14.1 configuration of d/a converter ........................................................................................ 157 14.2 functional outline of d/a converter ................................................................................ 157 14.3 output select blocks ....................................................................................................... .. 158 14.4 duty setting blocks and clock generation block .......................................................... 160 14.5 cautions on using d/a converter .................................................................................... 163 14.6 status on reset ............................................................................................................ ...... 164 15. serial interface .......................................................................................................... ........... 165 15.1 configuration of serial interface ...................................................................................... 166 15.2 functional outline of serial interface .............................................................................. 167 15.3 shift clock and serial data i/o pin control blocks ........................................................ 168 15.4 clock generation block .................................................................................................... 1 70 15.5 clock counter .............................................................................................................. ...... 172 15.6 presettable shift register (sio1sfr) .............................................................................. 173 15.7 wait control block ......................................................................................................... .... 175 15.8 outline of serial interface operation ............................................................................... 177 15.9 status of serial interface on reset .................................................................................. 178 16. pll frequency synthesizer ............................................................................................... 179 16.1 configuration of pll frequency synthesizer ................................................................. 179 16.2 functional outline of pll frequency synthesizer ......................................................... 180 16.3 input select block and programmable divider ............................................................... 181 16.4 reference frequency generator ...................................................................................... 186 16.5 phase comparator ( -det), charge pump, and unlock detection block ..................... 188 16.6 pll disabled status ........................................................................................................ .. 191 16.7 using pll frequency synthesizer ................................................................................... 191 16.8 status on reset ............................................................................................................ ...... 195 17. frequency counter ........................................................................................................... ... 196 17.1 outline of frequency counter .......................................................................................... 196 17.2 input/output select block and gate time control block ............................................... 197 17.3 start/stop control block and if counter ......................................................................... 200 17.4 using if counter function ................................................................................................ 20 6 17.5 error of external gate counter ......................................................................................... 208 17.6 status on reset ............................................................................................................ ...... 208 18. beep ........................................................................................................................ ...................... 209 18.1 general .................................................................................................................... ........... 209 18.2 i/o select block and output select block ....................................................................... 210 18.3 clock select block and clock generator block .............................................................. 212 18.4 output waveform of beep ................................................................................................ 213 18.5 status on reset ............................................................................................................ ...... 213
pd17012, 17p012 16 data sheet u10101ej4v0ds 19. lcd controller/driver ..................................................................................................... .. 214 19.1 configuration of lcd controller/driver ........................................................................... 214 19.2 functional outline of lcd controller/driver ................................................................... 215 19.3 lcd segment register ...................................................................................................... 2 17 19.4 segment signal/general-purpose output port select block ......................................... 220 19.5 common signal output timing control block and segment signal/key source signal output timing control block ................................ 222 19.6 output waveforms of common and segment signals ................................................... 224 19.7 using lcd controller/driver ............................................................................................. 228 19.8 status on reset ............................................................................................................ ...... 230 20. key source controller/decoder ................................................................................... 231 20.1 configuration of key source controller/decoder ........................................................... 231 20.2 functional outline of key source controller/decoder ................................................... 232 20.3 key source data setting block ......................................................................................... 233 20.4 output timing control blocks and segment/port select block .................................... 235 20.5 key input control block .................................................................................................... 239 20.6 using key source controller/decoder ............................................................................. 242 20.7 status on reset ............................................................................................................ ...... 250 21. standby ................................................................................................................... ................... 251 21.1 configuration of standby block ....................................................................................... 251 21.2 standby function ........................................................................................................... .... 252 21.3 selecting device operation mode with ce pin ............................................................... 252 21.4 halt function .............................................................................................................. ........ 254 21.5 clock stop function ........................................................................................................ .. 262 21.6 device operations in halt and clock stop status .......................................................... 265 21.7 notes on processing each pin in halt and clock stop status ...................................... 266 22. reset ....................................................................................................................... ..................... 269 22.1 configuration of reset block ........................................................................................... 269 22.2 reset function ............................................................................................................. ...... 270 22.3 ce reset ................................................................................................................... .......... 271 22.4 power-on reset ............................................................................................................. ..... 275 22.5 relationship between ce reset and power-on reset ................................................... 278 22.6 power failure detection .................................................................................................... 282 23. instruction set ............................................................................................................. .......... 290 23.1 outline of instruction set ................................................................................................. . 290 23.2 legend ..................................................................................................................... ........... 291 23.3 instruction set list ....................................................................................................... ..... 292 23.4 assembler (ra17k) embedded macro instructions ....................................................... 294 24. reserved symbols ............................................................................................................ ..... 295 24.1 data buffer (dbf) .......................................................................................................... ..... 295 24.2 system register (sysreg) .............................................................................................. 295 24.3 lcd segment register ...................................................................................................... 2 96 24.4 port register .............................................................................................................. ........ 297
pd17012, 17p012 17 data sheet u10101ej4v0ds 24.5 register file (control register) ........................................................................................ 298 24.6 peripheral hardware register ........................................................................................... 300 24.7 others ..................................................................................................................... ............ 300 25. one-time prom (program memory) write and verify ( pd17p012 only) ............... 301 25.1 operation modes for program memory write/verify ....................................................... 301 25.2 program memory write procedure ................................................................................... 302 25.3 program memory read procedure ................................................................................... 303 26. electrical specifications .................................................................................................. 3 04 27. package drawings ............................................................................................................ ...... 310 28. recommended soldering conditions ............................................................................. 312 appendix a. notes on connecting crystal resonator ................................................ 313 appendix b. development tools ............................................................................................. 314
pd17012, 17p012 18 data sheet u10101ej4v0ds 1. pin functions 1.1 pin function list (1) normal operation mode pin no. symbol function output format after power-on 64-pin 80-pin reset 63 77 p1a 2 3-bit i/o port (port 1a). input/output can be specified cmos input 1 80 p1a 1 in 1-bit units. push-pull 2 1 p1a 0 3 2 eo output from pll frequency synthesizer charge pump. cmos high impedance the division value of the local oscillation frequency 3-state and the phase of the reference frequency are compared at this pin, and the result is output. 4 3 (4) v dd1 positive power-supply pins. 5 v 10% is supplied to ?? 8 8, 9 v dd2 these pins. when only the cpu is operating, 3.5 to 5.5 v is supplied to these pins. 2.3 to 5.5 v is supplied when the clock is stopped. the same potential voltage is supplied to v dd1 and v dd2 . 5 5 vcol pll local oscillation frequency is input. ? input 6 6 vcoh 7 7 ce device selection and reset signal input. ? input 9 10 p0a 2 /sck 1 port 0a and serial interface i/o pins. cmos input 10 11 p0a 1 /so 1 p0a 2 to p0a 0 push-pull 11 12 p0a 0 /si 1 3-bit i/o port input/output can be specified in 1-bit units. sck 1 serial clock i/o so 1 serial data output si 1 serial data input 12 13 p1b 3 /fmifc port 1b. frequency counter input and analog input to ? input 13 14 p1b 2 /amifc a/d converter pins. 14 16 p1b 1 /adc 1 p1b 3 to p1b 0 15 17 p1b 0 /adc 0 4-bit input port fmifc, amifc frequency counter inputs adc 1 , adc 0 analog inputs to a/d converter remark the parenthesized value applies to the pd17p012.
pd17012, 17p012 19 data sheet u10101ej4v0ds pin no. symbol function output format after power-on 64-pin 80-pin reset 16 18 p0b 3 /fcg 1 port 0b. external gate counter input and beep output cmos input 17 19 p0b 2 /fcg 0 pins. push-pull 18 20 p0b 1 /beep 1 p0b 3 to p0b 0 19 21 p0b 0 /beep 0 4-bit i/o port input/output can be specified in 1-bit units. fcg 1 , fcg 0 external gate counter inputs beep 1 , beep 0 beep outputs 20 22 p1c 3 4-bit output port (port 1c) cmos low-level output 21 24 p1c 2 push-pull 22 25 p1c 1 23 26 p1c 0 24 27 x out pins for connecting crystal resonator for system clock cmos push-pull ? 25 28 x in oscillation. ? 26 30, 69 gnd ground pins. these pins must be connected to the ?? 58 31, 71 same potential. 27 33 p0c 3 port 0c. d/a converter output pins. n-ch low-level output 28 34 p0c 2 p0c 3 to p0c 0 open-drain 29 35 p0c 1 /pwm 1 4-bit output port (+12 v withstand 30 37 p0c 0 /pwm 0 pwm 1 , pwm 0 voltage) d/a converter outputs 31 38 p1d 3 4-bit i/o port (port 1d). input/output can be specified cmos input 32 39 p1d 2 in 4-bit units. push-pull 33 40 p1d 1 34 41 p1d 0 35 42 com 2 these pins output the common signals of the lcd cmos low-level output 36 44 com 1 controller/driver. ternary output 37 45 com 0 38 46 lcd 19 /p2h 0 port 2h, 2g, 2f, and 2e. lcd controller/driver cmos low-level output 39 47 lcd 18 /p2g 0 segment signal output pins. push-pull 40 48 lcd 17 /p2f 0 p2h 0 , p2g 0 , p2f 0 , p2e 0 41 49 lcd 16 /p2e 0 1-bit output ports lcd 19 to lcd 16 lcd controller/driver segment signal outputs
pd17012, 17p012 20 data sheet u10101ej4v0ds pin no. symbol function output format after power-on 64-pin 80-pin reset 42 to 50 lcd 15 /ks 15 /pya 15 port ya. segment signal output of lcd controller/ cmos low-level output 57 52 to driver and key source signal output of key matrix. push-pull 53 lcd 0 /ks 0 /pya 0 pya 15 to pya 0 55 ?16-bit output port to lcd 15 to lcd 0 67 ?lcd controller/driver segment signal outputs ks 15 to ks 0 ?key matrix key source signal outputs 59 to 73 p0d 3 /k 3 to port 0d. key source signal return input of lcd ? input with pull- 62 to p0d 0 /k 0 segment. down resistor 76 p0d 3 to p0d 0 ?4-bit input port k 3 to k 0 ?key source signal return inputs 64 78 int vector interrupt pin for edge detection. ? input rising or falling edge can be selected. (2) prom programming mode ( pd17p012 only) pin no. symbol function output format 64-pin 80-pin 4 3, 4 v dd1 positive power supply. supply +6 v to these pins when writing, reading, ? 8 8, 9 v dd2 or verifying the program memory. 12 to 13, 14, d 4 to d 7 8-bit data i/o when writing, reading, or verifying the program memory. cmos push-pull 15 16, 17 20 to 22, 24 d 0 to d 3 23 to 26 25 28 clk clock input to update addresses when writing, reading, or verifying the ? program memory. 26, 58 30, 69, gnd ground. ? 31, 71 59 to 73 to md 3 to md 0 input to select the operation mode when writing, reading, or verifying the ? 62 76 program memory. 64 78 v pp pin to apply the program voltage when writing, reading, or verifying the ? program memory. apply +12.5 v. remark pins not listed above are not used in the prom programming mode. for the processing of unused pins, refer to (2) pd17p012 (b) prom programming mode .
pd17012, 17p012 21 data sheet u10101ej4v0ds (i/o) 1.2 pin equivalent circuits (1) p0a (p0a 2 /sck 1 , p0a 1 /so 1 , p0a 0 /si 1 ) p0b (p0b 3 /fcg 1 , p0b 2 /fcg 0 , p0b 1 /beep 1 , p0b 0 /beep 0 ) p1a (p1a 2 , p1a 1 , p1a 0 ) p1d (p1d 3 , p1d 2 , p1d 1 , p1d 0 ) v dd v dd reset (other than p1d) read instruction (p1d only) (2) p1c (p1c 3 , p1c 2 , p1c 1 , p1c 0 ) lcd 15 /ks 15 /pya 15 to lcd 0 /ks 0 /pya 0 lcd 19 /p2h 0 , lcd 18 /p2g 0 , lcd 17 /p2f 0 , lcd 16 /p2e 0 , v dd (3) p0c (p0c 3 , p0c 2 , p0c 1 /pwm 1 , p0c 0 /pwm 0 ) (output) (output)
pd17012, 17p012 22 data sheet u10101ej4v0ds (4) p0d (p0d 3 /k 3 , p0d 2 /k 2 , p0d 1 /k 1 , p0d 0 /k 0 ) (input) (5) p1b (p1b 1 /adc 1 , p1b 0 /adc 0 ) (input) v dd a/d converter (6) p1b (p1b 3 /fmifc, p1b 2 /amifc) (input) v dd high on resistance v dd v dd v dd general-purpose port high-on resistance frequency counter
pd17012, 17p012 23 data sheet u10101ej4v0ds (schmitt trigger input) (7) ce int v dd (8) x out (output), x in (input) v dd v dd high-on resistance internal clock high on resistance x in x out (9) eo (output) v dd
pd17012, 17p012 24 data sheet u10101ej4v0ds (output) (input) (10) com 2 com 1 com 0 v dd v dd high-on resistance high-on resistance (11) vcoh vcol v dd v dd high-on resistance high-on resistance
pd17012, 17p012 25 data sheet u10101ej4v0ds 1.3 recommended connection of unused pins the following connections are recommended for unused pins. table 1-1. recommended connection of unused pins pin name i/o mode recommended connection of unused pins p0d 0 /k 0 to p0d 3 /k 3 input independently connect to gnd via a resistor note 1 . p1b 0 /adc 0 independently connect to v dd or gnd via a resistor note 1 . p1b 1 /adc 1 p1b 2 /amifc notes 2, 3 set to p1b 2 and connect to v dd or gnd via a resistor note 1 . p1b 3 /fmifc notes 2, 3 set to p1b 3 and connect to v dd or gnd via a resistor note 1 . p1c 0 /p1c 3 cmos push-pull output leave open. p2e 0 /lcd 16 p2f 0 /lcd 17 p2g 0 /lcd 18 p2h 0 /lcd 19 pya 0 /lcd 0 /ks 0 to pya 15 /lcd 15 /ks 15 p0c 0 /pwm 0 n-ch open-drain output set to low-level output by software, and leave open. p0c 1 /pwm 1 p0c 2 , p0c 3 p0a 0 /si 1 i/o note 4 set to general-purpose input port by software, and p0a 1 /so 1 independently connect to v dd or gnd via a resistor note 1 . p0a 2 /sck 1 p0b 0 /beep 0 p0b 1 /beep 1 p0b 2 /fcg 0 notes 2, 3 p0b 3 /fcg 1 notes 2, 3 p1a 0 to p1a 2 p1d 0 to p1d 3 ce input connect to v dd via a resistor note 1 . int note 5 connect to gnd via a resistor note 1 . vcoh, vcol disable by software, and leave open. com 0 to com 2 output leave open. eo notes 1. note that when pulling up (connecting to v dd via a resistor) or pulling down (connecting to gnd via a resistor) a pin externally using a high resistance value, the current consumption (through current) of the port increases because the pin approaches the high-impedance state. generally, a resistance value of several tens of k ? suffices for pull up and pull down, although this value depends on each application circuit. 2. this general-purpose input port has a circuit designed so that the current consumption does not increase even in the high-impedance state. 3. do not set this pin to amifc, fmifc, fcg 0 or fcg 1 , or the current consumption will increase. 4. these input/output ports become general-purpose input ports at power-on, clock stop, and ce reset. 5. in the pd17p012, the int pin functions alternately as the v pp pin for writing or verifying the program memory. if the int pin is not used, directly connect to gnd. port pins non-port pins
pd17012, 17p012 26 data sheet u10101ej4v0ds 1.4 notes on using ce and int pins the ce and int pins have a function to set a test mode (for ic test) in which the internal operations of the pd17012 and 17p012 are tested, in addition to the functions listed in 1.1 pin function list . in the pd17p012, the int pin functions alternately as the v pp pin for writing or verifying the program memory. if a voltage higher than v dd is applied to either of these pins, the test mode is set. therefore, if noise exceeding v dd is applied to these pins even during normal operation, the test mode may be set by mistake, affecting normal operation. noise may be superimposed on these pins if the length of the wiring of these pins is too long. therefore, keep the wiring length as short as possible. if noise is inevitable, take noise suppression measures by using an external component as illustrated below. connect a diode with low v f connect a capacitor between ce or int and v dd between ce or int and v dd v dd ce, int v dd diode with low v f v dd ce, int v dd
pd17012, 17p012 27 data sheet u10101ej4v0ds 2. program memory (rom) 2.1 outline of program memory figure 2-1 illustrates the program memory. as shown in this figure, the program memory consists of program memory and a program counter. the addresses of the program memory are specified by the program counter. the program memory has the following two major functions. (1) storing programs (2) storing constant data figure 2-1. outline of program memory instruction constant data program memory program counter address specification
pd17012, 17p012 28 data sheet u10101ej4v0ds 2.2 program memory figure 2-2 shows the configuration of the program memory. as shown in this figure, the program memory has a configuration of 4,096 steps 16 bits. therefore, program memory addresses are addresses 0000h to 0fffh. all instructions are 1-word instructions, 16 bits long, so that one instruction can be stored in one address of the program memory. the constant data in the program memory contents is read to the data buffer by using a table reference instruction. figure 2-2. configuration of program memory page 0 page 1 16 bits 4 k 2 k 0 0 0 0 h 0 7 f f h 0 f f f h 0 8 0 0 h 2.3 program counter figure 2-3 shows the configuration of the program counter. as shown in this figure, the program counter is configured as a 12-bit binary counter. the most significant bit, b 11 , indicates a page. the program counter specifies an address of the program memory. figure 2-3. configuration of program counter pc 11 pc 10 pc 9 pc 8 pc 7 pc 6 pc 5 pc 4 pc 3 pc 2 pc 1 pc 0 page pc
pd17012, 17p012 29 data sheet u10101ej4v0ds 2.4 program flow the execution flow of the program is controlled by the program counter, which specifies an address of the program memory. figure 2-4 shows the value set to the program counter when each instruction is executed. table 2-1 shows the vector address when an interrupt is acknowledged. 2.4.1 branch instructions (1) direct branch (?r addr? the branch destination address of the direct branch instruction is in the area of addresses 0000h to 0fffh, i.e. all the addresses of the program memory. (2) indirect branch (?r @ar? the branch destination address of the indirect branch instruction is in the area of addresses 0000h to 0fffh, i.e. all the addresses of the program memory. also refer to 5.3 address register (ar) . 2.4.2 subroutine (1) direct subroutine call (?all addr? the top address of the subroutine that can be called by the direct subroutine call instruction is within page 0 (addresses 0000h to 07ffh) in the program memory. (2) indirect subroutine call (?all @ar? the top address of the subroutine that can be called by the indirect subroutine call instruction is in the area of addresses 0000h to 0fffh, i.e. all the addresses of the program memory. also refer to 5.3 address register (ar) . 2.4.3 table referencing addresses that can be referenced by the table reference instruction ( movt dbf, @ar ) are in the area of addresses 0000h to 0fffh, i.e. all the addresses of the program memory. also refer to 5.3 address register (ar) and 9.2.2 table reference instruction (?ovt dbf, @ar? .
pd17012, 17p012 30 data sheet u10101ej4v0ds figure 2-4. specification of program counter on instruction execution table 2-1. interrupt vector address priority internal/external interrupt source vector address 1 external int pin 0004h 2 internal 12-bit timer 0003h 3 internal basic timer 1 0002h 4 internal serial interface 0001h program counter instruction br addr call addr br @ar call @ar movt dbf, @ar ret retsk reti when interrupt is acknowledged power-on reset, ce reset page 0 page 1 contents of program counter (pc) b 11 0 1 0 b 10 b 9 b 8 b 7 b 6 b 5 b 4 b 3 b 2 b 1 b 0 instruction operand (addr) instruction operand (addr) address register contents (return address) contents of address stack register (asr) specified by stack pointer (sp) vector address of each interrupt 000000000000
pd17012, 17p012 31 data sheet u10101ej4v0ds 3. address stack (ask) 3.1 outline of address stack figure 3-1 illustrates the address stack. the address stack consists of a stack pointer and address stack registers. the addresses of the address stack registers are specified by the stack pointer. the address stack saves a return address when a subroutine call instruction is executed or when an interrupt is acknowledged. the address stack is also used when a table reference instruction is executed. figure 3-1. outline of address stack stack pointer return address address stack register address specification 3.2 address stack registers (asr) figure 3-2 shows the configuration of the address stack registers. although there are six 12-bit address stack registers: asr0 to asr5, no register is assigned to asr5, and five 12-bit registers, asr0 to asr4, are used. the address stack saves a return address when a subroutine call instruction or table reference instruction is executed, or when an interrupt is acknowledged. figure 3-2. configuration of address stack registers stack pointer (sp) bit b 3 0 b 2 sp2 b 1 sp1 b 0 sp0 b 11 b 10 b 9 b 8 b 7 b 6 b 5 b 4 b 3 b 2 b 1 b 0 bit address stack registers (asr) address 0h 1h 2h 3h 4h 5h asr0 asr1 asr2 asr3 asr4 asr5 (undefined) cannot be used
pd17012, 17p012 32 data sheet u10101ej4v0ds 3.3 stack pointer (sp) figure 3-3 shows the configuration and function of the stack pointer. the stack pointer is a 4-bit binary counter. it specifies the address of an address stack register. the value of the stack pointer can be directly read or written by using a register manipulation instruction. figure 3-3. configuration and function of stack pointer name flag symbol b 3 0 b 2 s p 2 b 1 s p 1 b 0 s p 0 address 01h read/ write r/w 0 0 0 0 1 1 0 0 1 1 0 0 0 1 0 1 0 1 specifies address of address stack register (asr) address 0 (asr0) address 1 (asr1) address 2 (asr2) address 3 (asr3) address 4 (asr4) address 5 (asr5) fixed to ? power-on clock stop ce 01 1 1 0 0 0 1 1 1 stack pointer sp after reset
pd17012, 17p012 33 data sheet u10101ej4v0ds 3.4 operation of address stack 3.4.1 on execution of subroutine call (?all addr? ?all @ar? or return (?et? ?etsk? instruction when a subroutine call instruction is executed, the value of the stack pointer is decremented by one and a return address is saved to the address stack register specified by the stack pointer. when a return instruction is executed, the contents (return address) of the address stack register specified by the stack pointer are restored to the program counter, and the value of the stack pointer is incremented by one. 3.4.2 on execution of table reference instruction (?ovt dbf, @ar? when a table reference instruction is executed, the value of the stack pointer is decremented by one, and a return address is saved to the address stack register specified by the stack pointer. next, the contents of the program memory specified by the address register are read to the data buffer, the contents (return address) of the address stack register specified by the stack pointer are restored to the program counter, and then the value of the stack pointer is incremented by one. 3.4.3 on acknowledgement of interrupt and execution of return instruction (?eti? when an interrupt is acknowledged, the value of the stack pointer is decremented by one, and the return address is saved to the address stack register specified by the stack pointer. when a return instruction is executed, the contents (return address) of the address stack register specified by the stack pointer are restored to the program counter, and the value of the stack pointer is incremented by one. 3.4.4 on execution of address stack manipulation instruction (?ush ar? ?op ar? when the ?ush?instruction is executed, the value of the stack pointer is decremented by one, and the contents of the address register are transferred to the address stack register specified by the stack pointer. when the ?op?instruction is executed, the contents of the address stack register specified by the stack pointer are transferred to the address register, and the value of the stack pointer is incremented by one. 3.5 notes on using address stack the nesting level of the address stack is 5 and the value of the address stack register (asr5) is ?ndefined when the value of the stack pointer is 05h. do not use a subroutine call or interrupt exceeding level 5 without manipulating the stack; otherwise, execution returns to an undefined address.
pd17012, 17p012 34 data sheet u10101ej4v0ds 4. data memory (ram) 4.1 outline of data memory figure 4-1 illustrates the data memory. as shown in this figure, the data memory consists of a general-purpose data memory, system register, data buffer, lcd segment register, and port registers. the data memory stores data, transfers data with the peripheral hardware units, sets display data, transfers data with the ports, and controls the cpu. figure 4-1. outline of data memory peripheral hardware data transfer column address data memory bank0 data buffer port register 0 1 2 3 4 5 6 7 0123456789abcdef bank1 bank2 lcd segment register row address port data transfer lcd system register port register port register data transfer
pd17012, 17p012 35 data sheet u10101ej4v0ds 4.2 configuration and function of data memory figure 4-2 shows the configuration of the data memory. as shown in the figure, the data memory consists of banks. each bank consists of 128 nibbles with 7h row addresses and 0fh column addresses. the data memory can be divided by classification of function into the blocks explained in 4.2.1 through 4.2.6 below. the contents of the data memory can be operated, compared, judged, and transferred in 4-bit units by using a data memory manipulation instruction. table 4-1 lists the available data memory manipulation instructions. 4.2.1 system register (sysreg) the system register is allocated to addresses 74h to 7fh. because the system register is allocated to every bank, the identical system register exists at addresses 74h to 7fh of any bank. for details, refer to 5. system register (sysreg) . 4.2.2 data buffer (dbf) the data buffer is allocated to addresses 0ch to 0fh of bank0. for details, refer to 9. data buffer (dbf) . 4.2.3 lcd segment register the lcd segment register is allocated to addresses 5ch to 6fh of bank2. for details, refer to 19. lcd controller/driver . 4.2.4 port registers the port registers are allocated to addresses 70h to 73h of each bank. for details, refer to 10. general-purpose ports . 4.2.5 general-purpose data memory the general-purpose data memory is allocated to the addresses of the data memory excluding those of the system register, lcd segment register, and port registers. the general-purpose data memory of the pd17012 consists of a total of 316 nibbles (316 4 bits): 112 nibbles for each of bank0 and bank1, and 92 nibbles for bank2. 4.2.6 unallocated data memory data memory areas to which nothing is actually allocated exist in part of the port registers. for details of these data memory areas, refer to 4.4.2 notes on unallocated data memory and 10. general-purpose ports .
pd17012, 17p012 36 data sheet u10101ej4v0ds figure 4-2. configuration of data memory bank0 data memory 0 1 2 3 4 5 6 7 0123456789abcdef bank1 bank2 system register column address 0123456789abcdef column address 0 1 2 3 4 5 6 7 general register bank0 port register system register (sysreg) example address 1ah of bank0 b 3 b 2 b 1 b 0 0123456789abcdef 0 1 2 3 4 5 6 7 lcd segment register system register (sysreg) 0123456789abcdef 0 1 2 3 4 5 6 7 bank2 port register same system register exists. system register (sysreg) data buffer (dbf) row address row address row address row address port register bank1
pd17012, 17p012 37 data sheet u10101ej4v0ds table 4-1. data memory manipulation instructions function instruction operation addition add addc subtraction sub subc logical and or xor compare ske skge sklt skne transfer mov ld st judgement skt skf 4.3 addressing of data memory figure 4-3 shows addressing of the data memory. an address of the data memory is specified by a bank, a row address, and a column address. the row and column addresses are directly specified by using a data memory manipulation instruction. the bank is specified by the contents of the bank register. for details of the bank register, refer to 5. system register (sysreg) . figure 4-3. addressing of data memory bank register m data memory address b 3 b 2 b 1 b 0 b 2 b 1 b 0 b 3 b 2 b 1 b 0 bank row address column address instruction operand
pd17012, 17p012 38 data sheet u10101ej4v0ds 4.4 notes on using data memory 4.4.1 on power-on reset the contents of the general-purpose data memory are undefined on power-on reset. initialize the general-purpose data memory as necessary. 4.4.2 notes on unallocated data memory if a data memory manipulation instruction is executed to a data memory address to which nothing has been allocated, the following operations are performed. (1) device operation if a read instruction is executed, 0 is read. nothing is affected even if a write instruction is executed. (2) assembler (ra17k) operation assembly is performed normally. an error does not occur. (3) in-circuit emulator (ie-17k) operation if a read instruction is executed, 0 is read. nothing is affected even if a write instruction is executed. an error does not occur.
pd17012, 17p012 39 data sheet u10101ej4v0ds 5. system register (sysreg) 5.1 outline of system register figure 5-1 shows the location in the data memory and outline of the system register. as shown in this figure, the system register is allocated to addresses 74h to 7fh of each bank of the data memory. therefore, an identical system register exists at addresses 74h to 7fh of any bank. because the system register is located in the data memory, it can be manipulated by any data memory manipulation instruction. the system register consists of seven registers. figure 5-1. location on data memory and outline of system register column address 0 1 2 3 4 5 6 7 0123456789abcdef system register bank2 bank1 bank0 data memory row address address name function 74h 75h 76h 77h 78h 79h address register (ar) window register (wr) bank register (bank) address name function 7ah 7bh 7ch 7dh 7eh 7fh index register (ix) general register pointer (rp) program status word (psword) data memory row address pointer (mp) transfers data with register file. specifies bank of data memory. controls program memory address. modifies address of data memory. specifies address of general register controls operation.
pd17012, 17p012 40 data sheet u10101ej4v0ds 5.2 system register list figure 5-2 shows the configuration of the system register. figure 5-2. configuration of system register address name symbol bit data 74h 75h 76h 77h 78h 79h system register address register (ar) window register (wr) bank register (bank) ar3 ar2 ar1 ar0 wr bank b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 0 00 000 address name symbol bit data 7ah 7bh 7ch 7dh 7eh 7fh system register index register (ix) general register pointer (rp) program status word (psword) ixh mph ixm mpl ixl rph rpl psw b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 (ix) 00 data memory row address pointer (mp) (mp) 00 b c d c m p c y zi x e (rp) m p e
pd17012, 17p012 41 data sheet u10101ej4v0ds 5.3 address register (ar) 5.3.1 configuration of address register figure 5-3 shows the configuration of the address register. as shown in this figure, the address register consists of 16 bits, or 74h to 77h (ar3 to ar0) of the system register. however, since the higher 4 bits are always fixed to 0, this register actually operates as a 12-bit register. figure 5-3. configuration of address register address name symbol bit data note power-on clock stop ce 74h 75h ar3 ar2 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 0 0 0 0 0 0 address register (ar) b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 0 0 0 0 0 0 00 0 0 76h 77h ar1 ar0 m s b l s b after reset remark power-on: power-on reset clock stop: execution of clock stop instruction ce: ce reset note bits marked as ??are fixed to 0.
pd17012, 17p012 42 data sheet u10101ej4v0ds 5.3.2 function of address register the address register specifies a program memory address when a table reference (?ovt dbf, @ar?, stack manipulation (?ush ar? ?op ar?, indirect branch (?r @ar? or indirect subroutine call (?all @ar? instruction is executed. a dedicated instruction (?nc ar? that can increment the value of the address register by one is also available. the following paragraphs (1) through (5) explain the operations to be performed when the respective instructions are executed. (1) table reference instruction (?ovt dbf, @ar? this instruction reads the constant data (16-bit) of the program memory address specified by the contents of the address register to the data buffer. the addresses for storing constant data specified by the address register are 0000h to 0fffh. (2) stack manipulation instructions (?ush ar? ?op ar? when the ?ush ar?instruction is executed, the value of the stack pointer is decremented by one, and the contents of the address register (ar) are stored to the address stack register specified by the value of the decremented stack pointer. when the ?op ar?instruction is executed, the contents of the address stack register specified by the stack pointer are transferred to the address register, and the value of the stack pointer is incremented by one. (3) indirect branch instruction (?r @ar? this instruction branches execution to the program memory address specified by the contents of the address register. the branch addresses specified by the address register are 0000h to 0fffh. (4) indirect subroutine call instruction (?all @ar? this instruction calls the subroutine at the program memory address specified by the contents of the address register. the top address of the subroutine specified by the address register are 0000h to 0fffh. (5) address register increment instruction (?nc ar? this instruction increments the contents of the address register by one. because the address register of the pd17012 consists of 12 bits, its contents are cleared to 0000h if the ?nc ar?instruction is executed when the contents of the address register are 0fffh. 5.3.3 address register and data buffer the address register can transfer data via the data buffer as part of the peripheral hardware. for details, refer to 9. data buffer (dbf) .
pd17012, 17p012 43 data sheet u10101ej4v0ds 5.4 window register (wr) 5.4.1 configuration of window register figure 5-4 shows the configuration of the window register. as shown in the figure, the window register consists of 4 bits at address 78h of the system register. figure 5-4. configuration of window register address name symbol bit data power-on clock stop ce 78h window register (wr) wr b 3 b 1 b 0 undefined holds previous status m s b after reset l s b b 2 5.4.2 function of window register the window register is used to transfer data with the register file (rf) which is explained later. to transfer data between the window register and register file, the dedicated instructions peek wr, rf and poke rf, wr are used (rf: address of register file). the following paragraphs (1) and (2) explain the operations to be performed when each of these instructions is executed. also refer to 8. register file (rf) . (1) ?eek wr, rf?instruction when this instruction is executed, the contents of the register file addressed by rf are transferred to the window register. (2) ?oke rf, wr?instruction when this instruction is executed, the contents of the window register are transferred to the register file addressed by rf .
pd17012, 17p012 44 data sheet u10101ej4v0ds 5.5 bank register (bank) 5.5.1 configuration of bank register figure 5-5 shows the configuration of the bank register. as shown in the figure, the bank register consists of 4 bits at address 79h (bank) of the system register. actually, however, this register is a 2-bit register because the higher 2 bits are always fixed to 0. figure 5-5. configuration of bank register address name symbol bit data power-on clock stop ce 79h bank register (bank) bank b 3 0 b 2 0 b 1 b 0 0 0 0 m s b after reset l s b 5.5.2 function of bank register the bank register specifies a bank of the data memory. table 5-1 shows the relationship between the value of the bank register and the bank of the data memory specified by each value of the bank register. because the bank register exists on the system register, its contents can be rewritten no matter which bank may be currently specified. in other words, the bank register can be manipulated independently of the current status of the bank. table 5-1. specifying bank of data memory bank register (bank) b 3 0 0 0 0 b 2 0 0 0 0 b 1 0 0 1 1 b 0 0 1 0 1 bank0 bank1 bank2 setting prohibited data memory bank
pd17012, 17p012 45 data sheet u10101ej4v0ds 5.6 index register (ix) and data memory row address pointer (mp: memory pointer) 5.6.1 configuration of index register and data memory row address pointer figure 5-6 shows the configuration of the index register and data memory row address pointer. as shown in the figure, the index register consists of an index register (ix) and an index enable flag (ixe). ix is an 11-bit register consisting of the lower 3 bits (ixh) of system register address 7ah, and addresses 7bh and 7ch (ixm and ixl). ixe is the least significant bit of address 7fh (psw). the data memory row address pointer (memory pointer) consists of a data memory row address pointer, which consists of 7 bits with the lower 3 bits of address 7ah (mph) and address 7bh (mpl), and a data memory row address pointer enable flag (memory pointer enable flag: mpe), which is the most significant bit of address 7ah (mph). in other words, the higher 7 bits of the index register are shared with the data memory row address pointer. note, however, that the higher 2 bits of the index register and data memory row address pointer (bits b 2 and b 1 of address 7ah) are always fixed to 0. figure 5-6. configuration of index register and data memory row address pointer address name symbol bit data power-on clock stop ce 7ah index register (ix) ixh mph b 3 b 2 0 b 1 0 b 0 0 0 0 7bh ixm mpl b 3 b 2 b 1 b 0 0 0 0 7ch ixl b 3 b 2 b 1 b 0 0 0 0 7eh b 3 b 2 b 1 b 0 7fh psw b 3 b 2 b 1 b 0 0 0 0 memory pointer (mp) program status word (psword) ix mp after reset m p e m s b l s b i x e l s b m s b
pd17012, 17p012 46 data sheet u10101ej4v0ds 5.6.2 functions of index register and data memory row address pointer the index register and data memory row address pointer modify the addresses of the data memory. the following paragraphs (1) and (2) explain the functions of the index register and data memory row address pointer, respectively. a dedicated instruction ( inc ix ) that can increment the value of the address register by one is also available. for details on address modification, refer to 7. alu (arithmetic logic unit) block . (1) index register the index register modifies a specified data memory address according to the contents of the index register when a data memory manipulation instruction is executed. this modification, however, is valid only when the ixe flag is set to 1. to modify an address, the bank, row address, and column address of the data memory are ored with the contents of the index register, and the instruction is executed to the data memory whose address (called an actual address) is specified by the result of this or operation. all the data memory manipulation instructions are subject to address modification by the index register. the following instructions are not subject to modification by the index register. inc ar rorc r inc ix call addr movt dbf, @ar call @ar push ar ret pop ar retsk peek wr, rf reti poke rf, wr ei get dbf, p di put p, dbf stop s br addr halt h br @ar nop (2) data memory row address pointer the data memory row address pointer modifies the address at the indirect transfer destination when a general register indirect transfer instruction ( mov @r, m or mov m, @r ) is executed. however, this modification is valid only when the mpe flag is set to 1. to modify the address, the bank and row address at the transfer destination are replaced with the contents of the data memory row address pointer. instructions other than general register indirect transfer instructions are not subject to address modification. (3) index register increment instruction (?nc ix? this instruction increments the contents of the index register by one. because the index register is configured from 9 bits, the contents of the index register are cleared to 000h if the inc ix instruction is executed when the contents of the index register are 1ffh.
pd17012, 17p012 47 data sheet u10101ej4v0ds 5.7 general register pointer (rp) 5.7.1 configuration of general register pointer figure 5-7 shows the configuration of the general register pointer. as shown in this figure, the general register pointer consists of 7 bits: 4 bits of address 7dh (rph) of the system register and the higher 3 bits of address 7eh (rpl). however, because the higher 2 bits of address 7dh are always fixed to 0, actually the lower 5 bits of this register (the lower 2 bits of address 7dh and the higher 3 bits of address 7eh) are valid. figure 5-7. configuration of general register pointer address name symbol bit data power-on clock stop ce 7dh 7eh general register pointer (rp) rph rpl b 3 0 b 2 0 b 1 b 0 b 3 b 2 b 1 b 0 0 0 0 0 0 0 m s b after reset l s b b c d
pd17012, 17p012 48 data sheet u10101ej4v0ds 5.7.2 function of general register pointer the general register pointer specifies a general register in the data memory. figure 5-8 shows the address of the general register specified by the general register pointer. as shown in the figure, the higher 4 bits of the general register pointer (rph: address 7dh) specify a bank, and the lower 3 bits (rpl: address 7eh) specify a row address. because the valid number of bits of the general register pointer is 5, the row addresses (0h to 7h) of bank0 and bank1 can be specified as general registers. for details on the operations of the general registers, refer to 6. general register (gr) . figure 5-8. address of general register specified by general register pointer general register pointer (rp) rph rpl b 3 0 b 2 0 b 1 b 0 b 3 b 2 b 1 b 0 specifies row address of each bank bank bank0 bank1 bank2 row address 0h 1h 2h 3h 4h 5h 6h 7h 000 0 0 0 0 0 1 1 0 0 0 1 1 1 0 0 0 0 0 0 1 1 1 1 0 0 1 1 0 0 1 1 0 1 0 1 0 1 0 1 m s b l s b b c d specifies bank 5.7.3 notes on using general register pointer the least significant bit of address 7eh (rpl) to which the general register pointer is allocated is used as the bcd flag of the program status word. when rewriting the value of rpl, therefore, pay attention to the value of the bcd flag.
pd17012, 17p012 49 data sheet u10101ej4v0ds 5.8 program status word (psword) 5.8.1 configuration of program status word figure 5-9 shows the configuration of the program status word. as shown in the figure, the program status word consists of 5 bits: the least significant bit of address 7eh (rpl) of the system register and the 4 bits of the address 7fh (psw). the program status word consists of five flags, each of which functions independently: bcd (bcd), compare (cmp), carry (cy), zero (z), and index enable (ixe) flags. figure 5-9. configuration of program status word address name symbol bit data power-on clock stop ce 7eh 7fh program status word (psword) rpl psw b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 0 0 0 0 0 0 (rp) b c d after reset c m p c y zi x e
pd17012, 17p012 50 data sheet u10101ej4v0ds 5.8.2 function of program status word the program status word is a register that sets the condition of an operation or transfer instruction of the alu (arithmetic logic unit) or indicates the result of an executed operation. table 5-2 outlines the function of each flag of the program status word. for details, refer to 7. alu (arithmetic logic unit) block . table 5-2. functional outline of program status word 5.8.3 notes on using program status word if an arithmetic operation (addition or subtraction) instruction is executed for the program status word, the result of the arithmetic operation is stored in the program status word. for example, even if an operation that causes a carry to occur is executed, if the result of the operation is 0000b, 0000b is stored in the psw. 5.9 notes on using system register the data of the system register fixed to 0 is not affected even if a write instruction is executed to it. this data is always 0 when it is read. program status word (psword) rpl psw b 3 b 2 b 1 b 0 b c d b 3 c m p b 2 c y b 1 z b 0 i x e flag name index enable flag (ixe) zero flag (z) carry flag (cy) compare flag (cmp) bcd flag (bcd) function (rp) this flag modifies the address of the data memory when a data memory manipulation instruction is executed. 0: no modification 1: modification this flag indicates that the result of an arithmetic operation executed is 0. note that the status of 0 or 1 differs depending on the contents of the compare flag. this flag indicates the occurrence of a carry or borrow as a result of execution of an addition or subtraction instruction. it is reset to 0 if a carry/borrow does not occur; it is set to 1 if a carry/borrow occurs. this flag is also used as the shift bit of the rorc r instruction. this flag is used avoid storing the result of an arithmetic operation to the data memory or general register. 0: result stored 1: result not stored this flag is used to execute an arithmetic operation in decimal. 0: binary operation executed 1: decimal operation executed
pd17012, 17p012 51 data sheet u10101ej4v0ds 6. general register (gr) 6.1 outline of general register figure 6-1 illustrates the general register. as shown in the figure, the general register consists of a general register pointer and general register body. the bank and row address of the general register body are specified by the general register pointer. the general register body is used to transfer data and execute operations between data memory addresses. figure 6-1. outline of general register column address system register bank2 bank1 bank0 data memory general register transfer, operation general register pointer row address 6.2 general register body the general register body consists of 16 nibbles (16 4 bits) at the same row addresses in the data memory. for the range of the banks and row addresses that can be specified by the general register pointer and general register, refer to 5.7 general register pointer (rp) . the 16 nibbles of the same row address specified as a general register executes operations and transfers data with the data memory using a single instruction. in other words, operations or transfer between data memory addresses can be executed with a single instruction. the general register can be controlled by a data memory manipulation instruction like the other data memory areas.
pd17012, 17p012 52 data sheet u10101ej4v0ds 6.3 address generation of general register by instructions the following subsections 6.3.1 and 6.3.2 explain how the addresses of the general register are generated when each instruction is executed. for details of the operation of each instruction, refer to 7. alu (arithmetic logic unit) block . 6.3.1 addition (?dd r, m? ?ddc r, m?, subtraction (?ub r, m? ?ubc r, m?, logical operation (?nd r, m? ?r r, m? ?or r, m?, direct transfer (?d r, m? ?t m, r?, and rotation processing (?orc r? instructions table 6-1 shows the address of general register ??specified by operand ??of an instruction. only the column address is specified as operand ?? table 6-1. address generation of general register contents of general register pointer r r general register address b 3 b 2 b 1 b 0 b 2 b 1 b 0 b 3 b 2 b 1 b 0 bank row address column address 6.3.2 indirect transfer (?ov @r,m? ?ov m, @r? instructions table 6-2 shows the address of the general register r specified by operand r of an instruction and an indirect transfer address specified by @r . table 6-2. address generation of general register contents of general register pointer r r general register address b 3 b 2 b 1 b 0 b 2 b 1 b 0 b 3 b 2 b 1 b 0 bank row address column address same as data memory contents of r @r indirect transfer address
pd17012, 17p012 53 data sheet u10101ej4v0ds 6.4 notes on using general register 6.4.1 row address of general register note that because the row address of the general register is specified by the general register pointer, the bank currently specified may differ from the bank of the general register. 6.4.2 operation between general register and immediate data no instruction that executes an operation between the general register and immediate data is provided. to execute an operation between the general register and immediate data, the general register must be treated as a data memory area.
pd17012, 17p012 54 data sheet u10101ej4v0ds 7. alu (arithmetic logic unit) block 7.1 outline of alu block figure 7-1 outlines the alu block. as shown in the figure, the alu block consists of an alu, temporary registers a and b, a program status word, decimal adjuster, and data memory address controller. the alu operates, judges, compares, rotates, and transfers 4-bit data in the data memory. figure 7-1. outline of alu block data bus address control data memory index modification memory pointer temporary register a temporary register b program status word carry/borrow/ zero detection/decimal/ storage specification alu ?arithmetic operation ?logical operation ?bit judgment ?comparison ?rotation processing ?transfer decimal adjustment
pd17012, 17p012 55 data sheet u10101ej4v0ds 7.2 configuration and function of each block 7.2.1 alu the alu executes arithmetic or logical operations, bit judgment, comparison, rotation processing, and transfer of 4-bit data according to an instruction specified by the program. 7.2.2 temporary registers a and b temporary registers a and b temporarily store 4-bit data. these registers are automatically used when an instruction is executed and are not controlled by the program. 7.2.3 program status word the program status word controls the operation of the alu and stores the status of the alu. for details of the program status word, refer to 5.8 program status word (psword) . 7.2.4 decimal adjuster if the bcd flag of the program status word is set to 1 as a result of an executed arithmetic operation, the arithmetic operation result is converted into a decimal number by the decimal adjuster. 7.2.5 address controller the address controller specifies an address of the data memory. at this time, address modification by the index register and data memory row address pointer is also controlled. 7.3 alu processing instruction list table 7-1 lists the alu operations when each instruction is executed. table 7-2 shows modification of data memory addresses by the index register and data memory row address pointer. table 7-3 shows the decimal adjustment data when a decimal operation is executed.
pd17012, 17p012 56 data sheet u10101ej4v0ds ------------------------------------------------------------------------------------------------------------------------------- ---------- table 7-1. list of alu processing instruction operations alu instruction difference in operation based on program status word (psword) address modification function value of value of arithmetic operation of operation of z flag index memory bcd flag cmp flag operation cy flag pointer addition add r, m 0 0 stores result of set if carry or set if result of operation executed not m, #n4 binary operation. borrow occurs; is 0000b; otherwise, reset. executed addc r, m 0 1 does not store otherwise, reset. holds status if result of m, #n4 result of binary operation is 0000b; operation. otherwise, reset. subtrac- sub r, m 1 0 stores result of set if result of operation is tion m, #n4 decimal operation. 0000b; otherwise, reset. subc r, m 1 1 does not store holds status if result of m, #n4 result of decimal operation is 0000b; otherwise, operation. reset. logical or r, m any any not affected holds previous holds previous status. executed not operation m, #n4 (held) (held) status. executed and r, m m, #n4 xor r, m m, #n4 judgment skt m, #n any any not affected holds previous holds previous status. executed not skf m, #n (held) (reset) status. executed compare ske m, #n4 any any not affected holds previous holds previous status. executed not skne m, #n4 (held) (held) status. executed skge m, #n4 sklt m, #n4 transfer ld r, m any any not affected holds previous holds previous status executed not st m, r (held) (held) status executed mov m, #n4 @r, m executed m, @r rotation rorc r any any not affected value of general holds previous value not not (held) (held) register b 0 executed executed
pd17012, 17p012 57 data sheet u10101ej4v0ds table 7-2. modification of data memory address and modification of indirect transfer address by index register and data memory row address pointer b 3 b 2 b 1 b 0 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 2 b 1 b 0 b 3 b 2 b 1 b 0 general register address specified by r data memory address specified by m indirect transfer address specified by @r bank row address column address bank row address column address bank row address column address rp r bank m bank m r (r) ditto mp (r) ditto bank m bank m r ix (r) or mp (r) ditto ditto ditto mpe 0 1 0 1 ixe 0 0 1 1 ixh, ixm logical or logical bank: bank register ix: index register ixe: index enable flag ixh: bits 10 through 8 of index register ixm: bits 7 through 4 of index register ixl: bits 3 through 0 of index register m: data memory address indicated by m r , m c m r : data memory row address (higher) m c : data memory column address (lower) mp: data memory row address pointer mpe: memory pointer enable flag r: general register column address rp: general register pointer (x): contents addressed by x x: direct address such as m and r
pd17012, 17p012 58 data sheet u10101ej4v0ds table 7-3. decimal adjustment data operation result hexadecimal addition decimal addition operation result hexadecimal subtraction decimal subtraction cy operation result cy operation result cy operation result cy operation result 0 0 0000b 0 0000b 0 0 0000b 0 0000b 1 0 0001b 0 0001b 1 0 0001b 0 0001b 2 0 0010b 0 0010b 2 0 0010b 0 0010b 3 0 0011b 0 0011b 3 0 0011b 0 0011b 4 0 0100b 0 0100b 4 0 0100b 0 0100b 5 0 0101b 0 0101b 5 0 0101b 0 0101b 6 0 0110b 0 0110b 6 0 0110b 0 0110b 7 0 0111b 0 0111b 7 0 0111b 0 0111b 8 0 1000b 0 1000b 8 0 1000b 0 1000b 9 0 1001b 0 1001b 9 0 1001b 0 1001b 10 0 1010b 1 0000b 10 0 1010b 1 1100b note 11 0 1011b 1 0001b 11 0 1011b 1 1101b note 12 0 1100b 1 0010b 12 0 1100b 1 1110b note 13 0 1101b 1 0011b 13 0 1101b 1 1111b note 14 0 1110b 1 0100b 14 0 1110b 1 1100b note 15 0 1111b 1 0101b 15 0 1111b 1 1101b note 16 1 0000b 1 0110b 16 1 0000b 1 1110b note 17 1 0001b 1 0111b 15 1 0001b 1 1111b note 18 1 0010b 1 1000b 14 1 0010b 1 1100b note 19 1 0011b 1 1001b 13 1 0011b 1 1101b note 20 1 0100b 1 1110b note 12 1 0100b 1 1110b note 21 1 0101b 1 1111b note 11 1 0101b 1 1111b note 22 1 0110b 1 1100b note 10 1 0110b 1 0000b 23 1 0111b 1 1101b note 9 1 0111b 1 0001b 24 1 1000b 1 1110b note 8 1 1000b 1 0010b 25 1 1001b 1 1111b note 7 1 1001b 1 0011b 26 1 1010b 1 1100b note 6 1 1010b 1 0100b 27 1 1011b 1 1101b note 5 1 1011b 1 0101b 28 1 1100b 1 1010b note 4 1 1100b 1 0110b 29 1 1101b 1 1011b note 3 1 1101b 1 0111b 30 1 1110b 1 1100b note 2 1 1110b 1 1000b 31 1 1111b 1 1101b note 1 1 1111b 1 1001b note the operation results are not correctly adjusted by the decimal adjustment circuit.
pd17012, 17p012 59 data sheet u10101ej4v0ds 7.4 notes on using alu 7.4.1 notes on using operations for program status word if an arithmetic operation is executed for the program status word, the result of the arithmetic operation is stored in the program status word. the cy and z flags of the program status word are set or reset depending on the result of the arithmetic operation. if an arithmetic operation is executed on the program status word itself, the result of the operation is stored in the program status word, which makes it impossible to judge occurrence of a carry or a borrow, or whether the result of the operation is zero. if the cmp flag is set, however, the result of the operation is not stored in the program status word, and the cy and z flags are set or reset normally. 7.4.2 notes on using decimal operations a decimal operation can be executed only if the result falls within the following range: (1) result of addition: 0 to 19 in decimal (2) result of subtraction: 0 to 9 or 10 to 1 in decimal if a decimal operation is executed exceeding this range, the cy flag is set, and the result is a value greater than 1010b (0ah).
pd17012, 17p012 60 data sheet u10101ej4v0ds 8. register file (rf) 8.1 outline of register file figure 8-1 illustrates the register file. as shown in the figure, the register file consists of control registers existing on a space different from that of the data memory, and a portion overlapping the data memory. the control registers set the conditions of the peripheral hardware units. data is read from or written to the register file via the window register. figure 8-1. outline of register file control registers (separate space from data memory) (space same as data memory) data is manipulated via window register 0 1 2 3 4 5 6 7 system register window register peripheral hardware register file row address
pd17012, 17p012 61 data sheet u10101ej4v0ds 8.2 configuration and function of register file figure 8-2 shows the configuration of the register file and its relationship with the data memory. addresses are allocated to the register file in 4-bit units, like the data memory, and the register file has a total of 128 nibbles with row addresses 0h to 7h and column addresses 0h to 0fh. control registers that set the conditions of the peripheral hardware units are allocated to addresses 00h to 3fh. addresses 40h to 7fh overlap the data memory. to put it another way, the addresses 40h to 7fh of the register file are the memory addresses of the data memory bank currently selected. these addresses, 40h to 7fh, can be treated in the same manner as the normal data memory areas, except that they can be manipulated by a register file manipulation instruction (peek wr, rf or poke rf, wr), because they overlap the data memory. figure 8-2. configuration of register file and its relationship with data memory column address bank0 0 1 2 3 4 5 6 7 0123456789abcdef system register data memory bank1 bank2 0 1 2 3 control register register file row address
pd17012, 17p012 62 data sheet u10101ej4v0ds 8.3 register file manipulation instructions (?eek wr, rf?and ?oke rf, wr? data is read from or written to the register file via the window register in the system register by using a register file manipulation instruction ( peek wr, rf or poke rf, wr ). the operation of each instruction is explained below. (1) ?eek wr, rf this instruction reads the data of the register file addressed by rf to the window register. (2) ?oke rf, wr this instruction writes the data of the window register to the register file addressed by rf . 8.4 control registers figure 8-3 shows the configuration of the control registers. as shown in this figure, a total of 64 nibbles (64 words 4 bits) at addresses 00h to 3fh of the register file can be used as control registers. of these nibbles, however, 33 nibbles are actually used. the remaining 31 nibbles are unused registers that are prohibited from being read or written. each control register has an attribute of 1 nibble, and is classified into four types: read/write (r/w), read- only (r), write-only (w), and read-and-reset (r & reset). nothing is changed even if data is written to a read-only (r and r & reset) register. an undefined value is read if a write-only (w) register is read. of the 4-bit data in 1 nibble, the bit fixed to 0 is always 0 when it is read or written. the 31 nibbles of unused registers are undefined when they are read, and nothing is changed when data is written to them.
pd17012, 17p012 63 data sheet u10101ej4v0ds figure 8-3. configuration of control registers (1/2) column address name symbol read/ write row address item stack pointer (sp) 01234567 0 serial i/o mode select register i/f count gate judge register pll unlock ff judge register a/d converter compare judge register ce pin level judge register 0 (8) note name symbol read/ write 1 (9) note name symbol read/ write 2 (a) name symbol read/ write 3 (b) note s p 2 ( ( s p 1 ( ( s p 0 ( ( s i o 1 t s s i o 1 h i z s i o 1 c k 1 s i o 1 c k 0 000 i f c g 000p l l u l 000c e 000a d c c m p r/w r/w r r & reset r r if counter mode select register i f c m d 1 r/w if counter control register beep clock select register fcg channel select register 0 r/w pll reference clock select register p l l r f c k 3 r/w lcd mode select register lcd port select register beep select register pwm mode select register a/d converter channel select register key input judge register basic timer 0 carry ff judge register pll mode select register port 1d group i/o select register port 1a bit i/o select register port 0a bit i/o select register port 0b bit i/o select register r/w r/w w r/w r/w r/w r/w r/w r/w r/w r/w r & reset r & reset i f c m d 0 i f c c k 1 i f c c k 0 00a d c c h 1 a d c c h 0 000k e y j 000b t m 0 c y p y a s e l l c d e n k s e n 0p w m 0 s e l p w m 1 s e l 0 0 p 2 e s e l p 2 f s e l p 2 g s e l p 2 h s e l b e e p 0 s e l b e e p 1 s e l 0 0 0p l l m d 1 p l l m d 0 00 i f c s t r t i f c r e s 00f c g c h 1 f c g c h 0 b e e p 1 c k 1 b e e p 1 c k 0 b e e p 0 c k 1 b e e p 0 c k 0 000p 1 d g i o p l l r f c k 2 p l l r f c k 1 p l l r f c k 0 0p 1 a b i o 2 p 1 a b i o 1 p 1 a b i o 0 p 0 b b i o 3 p 0 b b i o 2 p 0 b b i o 1 p 0 b b i o 0 0p 0 a b i o 2 p 0 a b i o 1 p 0 a b i o 0 r/w note addresses in parentheses are for when an assembler (ra17k) is used.
pd17012, 17p012 64 data sheet u10101ej4v0ds figure 8-3. configuration of control registers (2/2) basic timer clock select register 89abcdef 12-bit timer clock select register 12-bit timer overflow register 12-bit timer control register b t m 1 c k 1 b t m 1 c k 0 b t m 0 c k 1 b t m 0 c k 0 000t m c k 000t m o v f 0t m r p t t m r e s t m e n r/w r/w r r/w interrupt request register 4 0 r/w interrupt edge select register interrupt enable register interrupt request register 3 interrupt request register 1 interrupt request register 2 r/w r/w r/w r/w r/w 000 i e g i p s i o 1 i p b t m 1 i p t m i p 00 i r q s i o 1 000 i r q b t m 1 000 i r q t m i n t 00 i r q r
pd17012, 17p012 65 data sheet u10101ej4v0ds table 8-1. peripheral hardware control functions of control registers (1/4) control register peripheral hardware control function after reset b 3 name address read/ b 2 functional outline set value write b 1 b 0 01 0 0 fixed to 0 27h r/w 000 0 p1dgio i/o setting of port 1d (group i/o) input output 0 fixed to 0 p1abio2 35h r/w p1abio1 p1a 2 pin p1abio0 p1a 1 pin p1a 0 pin p0bbio3 p0b 3 pin i/o setting (bit i/o) input output 0 0 0 p0b 2 pin p0bbio2 p0b 1 pin 36h r/w p0b 0 pin p0bbio1 p0bbio0 0 fixed to 0 p0abio2 37h r/w p0a 2 pin p0abio1 p0a 1 pin i/o setting (bit i/o) input output 0 0 0 p0a 0 pin p0abio0 0 0 fixed to 0 1fh r/w 000 0 ieg sets interrupt issuance edge (int) rising edge falling edge ipsio1 serial interface ipbtm1 basic timer 1 disables enables 2fh r/w 12-bit timer enables interrupt interrupt interrupt 0 0 0 iptm int pin ip 0 0 fixed to 0 3ch r/w 000 0 irqsio1 detects interrupt request (serial interface) not requested requested 0 0 fixed to 0 3dh r/w 000 0 irqbtm1 detects interrupt request (basic timer 1) not requested requested 0 0 fixed to 0 3eh r/w 000 0 irqtm detects interrupt request (12-bit timer) not requested requested power-on general-purpose ports interrupts port 1d group i/o select register port 1a bit i/o select register port 0b bit i/o select register port 0a bit i/o select register interrupt edge select register interrupt enable register interrupt request register 4 interrupt request register 3 interrupt request register 2 CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCC CCCCCCCCC CCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCC CCCCCCCCC CCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCC CCCCCCCCC CCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCC CCCCCCCCC CCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCC CCCCCCCCC CCCCCCCCC CCCCCCCCC CCCCCCCCC CCCCCCCCC CCCCCCCCC CCCCCCCCC CCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCC CCCCCCCCC CCCCCCCCC CCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCC CCCCCCCCC s t o p c e peripheral hardware
pd17012, 17p012 66 data sheet u10101ej4v0ds control register peripheral hardware control function after reset b 3 name address read/ b 2 functional outline set value write b 1 b 0 01 r int detects status of int pin low level high level 0 3fh fixed to 0 000 r/w 0 irq detects interrupt request (int pin) not requested requested btm1ck1 sets clock of basic timer 1 btm1ck0 09h r/w 00 btm0ck1 sets clock of basic timer 0 btm0ck0 0 0 fixed to 0 0ch r/w 00 0 tmck sets clock of 12-bit timer 50 s 10 s 0 0 fixed to 0 0dh r 00 0 tmovf detects overflow of timer/counter no overflow overflow 0 fixed to 0 tmrpt selects operation mode of 12-bit timer free-run count mode modulo count mode 0eh r/w 00 tmres resets timer/counter does not reset resets tmen sets operation of timer/counter does not operate operates 0 r& 0 fixed to 0 17h reset 011 0 btm0cy detects status of carry ff reset set 0 0 fixed to 0 06h r 0 adccmp detects comparison result v adcin < v ref v adcin > v ref 0 fixed to 0 0 14h r/w 333 adcch1 selects pins to be used for a/d converter adcch0 0 fixed to 0 0 13h r/w 00 pwm1sel pwm 1 pin general- set for d/a converter purpose d/a converter pwm0sel pwm 0 pin output port table 8-1. peripheral hardware control functions of control registers (2/4) peripheral hardware power-on interrupts d/a converter a/d converter timers CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CC C CCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCC CCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCC CCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCC CCCCCCCCC CCCCCCCCC CCCCCCCCC CCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCC CCCCCCCCC CCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCC CCCCCCCCC CCCCCCCCC CCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCC CCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCC CCCCCCCCC CCCCCCCCC 00 11 adc 0 adc 1 not used not used 01 01 interrupt request register 1 basic timer clock select register 12-bit timer clock select register 12-bit timer overflow register 12-bit timer control register basic timer 0 carry ff judge register a/d converter compare judge register a/d converter channel select register pwm mode select register retained retained retained retained retained retained retained 00 11 100 ms 250 ms 5 ms 1 ms 01 01 00 11 100 ms 250 ms 5 ms 1 ms 01 01 undefined s t o p c e
pd17012, 17p012 67 data sheet u10101ej4v0ds control register peripheral hardware control function after reset b 3 name address read/ b 2 functional outline set value write b 1 b 0 01 sio1ts starts/stops operation stops operation starts operation sio1hiz sets so 1 pin as serial output pin serial output 02h r/w 000 sio1ck1 sets clock of serial interface sio1ck0 0 0 fixed to 0 05h r&reset 0 pllul detects status of unlock ff lock status unlock status 0 fixed to 0 0 21h r/w 00 pllmd1 sets division method of pll pllmd0 pllrfck3 pllrfck2 31h r/w sets reference frequency of pll f f pllrfck1 pllrfck0 0 0 fixed to 0 04h r 00 0 ifcg detects opening/closing of gate of frequency counter close open ifcmd1 sets mode of frequency counter ifcmd0 12h r/w 00 ifcck1 sets gate time of frequency counter ifcck0 0 fixed to 0 0 23h w 00 ifcstrt starts counting of if counter does not start starts ifcres resets if counter does not reset resets 0 fixed to 0 0 24h r/w 33 fcgch1 sets pin to be used as fcg fcgch0 0 fixed to 0 0 15h r/w 000 beep1sel beep 1 pin general- set as beep purpose beep beep0sel beep 0 pin i/o port table 8-1. peripheral hardware control functions of control registers (3/4) general-purpose i/o port peripheral hardware power-on CCCCCCCCC CCCCCCCCC CCCCCCCCC CCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCC CCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCC CCCCCCCCC CCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCC CCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCC CCCCCCCCC CCCCCCCCC serial i/o mode select register pll unlock ff judge register pll mode select register pll reference clock select register if counter gate judge register if counter mode select register if counter control register fcg channel select register beep select register CCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCC CCCCCCCCC CCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCC CCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCC CCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCC CCCCCCCCC CCCCCCCCC retained retained retained retained retained retained retained retained undefined 00 11 disable mf vhf hf 01 01 0: 1.25 khz, 1: 2.5 khz, 2: 5 khz, 3: 10 khz, 4: 6.25 khz, 5: 12.5 khz, 6: 25 khz, 7: 50 khz, 8: 3 khz, 9, a, b: setting prohibited, c: 1 khz, d: 9 khz, e: 100 khz, f: off 00 11 fcg amifc pin fmifc pin fmifc pin amif mode fmif mode amif mode 01 01 00 11 1 ms 4 ms 8 ms open 1 khz 100 khz 900 khz 01 01 00 11 fcg 0 fcg 1 not not used used 01 01 beep frequency counter pll frequency synthesizer serial interface 00 11 external 37.5 khz 75 khz 450 khz clock 01 01 s t o p c e
pd17012, 17p012 68 data sheet u10101ej4v0ds control register peripheral hardware control function after reset b 3 name address read/ b 2 functional outline set value write b 1 b 0 01 beep1ck1 sets output frequency of beep 1 beep1ck0 25h r/w 00 beep0ck1 sets output frequency of beep 0 beep0ck0 0 fixed to 0 ksen sets key source output signal key source off key source on 10h r/w lcden sets lcd display output display off display on pyasel 00 p2hsel pya 0 -pya 15 pins p2h 0 pin set as general- general- p2gsel p2g 0 pin purpose output lcd segment purpose 11h r/w p2f 0 pin port output port p2fsel p2e 0 pin p2esel 0 0 fixed to 0 16h r&reset 000 0 keyj detects if key input latch is valid latch invalid latch valid 0 0 fixed to 0 07h r CCC 0 ce detects status of ce pin low level high level remark C : determined according to the status of the pin. 8.5 notes on using register file note the following points (1) through (3) when manipulating the write-only registers (w), read-only registers (r), and unused registers of the control registers (addresses 00h to 3fh of the register file). (1) when a write-only register is read, an undefined value is read. (2) nothing is changed even if data is written to a read-only register. (3) an undefined value is read if an unused register is read. nothing is changed even if data is written to an unused register. table 8-1. peripheral hardware control functions of control registers (4/4) peripheral hardware power-on CCCCCCCCC CCCCCCCCC CCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCC beep clock select register lcd mode select register lcd port select register key input judge register ce pin level judge register CCCCCCCCC CCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCC CCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCC 00 11 1 khz 3 khz 200 hz 9 khz 01 01 00 11 1 khz 3 khz 200 hz 9 khz 01 01 CCCCCCCCC retained CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCC CCCCCCCCC retained CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCC standby lcd controller/driver beep s t o p c e CCCCCCCCC
pd17012, 17p012 69 data sheet u10101ej4v0ds 9. data buffer (dbf) 9.1 outline of data buffer figure 9-1 illustrates the data buffer. the data buffer is located in the data memory and has the following two functions: (1) reads constant data from program memory (table reference) (2) transfers data with peripheral hardware unit figure 9-1. outline of data buffer data buffer data write (put) data read (get) table reference (movt) peripheral hardware constant data program memory
pd17012, 17p012 70 data sheet u10101ej4v0ds 9.2 data buffer 9.2.1 configuration of data buffer figure 9-2 shows the configuration of the data buffer. as shown in the figure, the data buffer consists of a total of 16 bits at addresses 0ch to 0fh of bank 0 on the data memory. the 16-bit data consists of bit b 3 at address 0ch as the msb and bit b 0 at address 0fh as the lsb. because the data buffer is located in the data memory, it can be manipulated by all data memory manipulation instructions. figure 9-2. configuration of data buffer column address bank0 0 1 2 3 4 5 6 7 bank1 7 data memory bank2 7 system register data buffer (dbf) address bit bit signal data b 3 b 15 b 2 b 14 b 1 b 13 b 0 b 12 dbf3 0ch b 3 b 11 b 2 b 10 b 1 b 9 b 0 b 8 dbf2 0dh b 3 b 7 b 2 b 6 b 1 b 5 b 0 b 4 dbf1 0eh b 3 b 3 b 2 b 2 b 1 b 1 b 0 b 0 dbf0 0fh data memory data buffer 0123456789abcdef row address m s b l s b data
pd17012, 17p012 71 data sheet u10101ej4v0ds 9.2.2 table reference instruction (?ovt dbf, @ar? the operation of the ?ovt dbf, @ar?instruction is indicated below. movt dbf, @ar this instruction reads the contents of the program memory addressed by the contents of the address register to the data buffer. one stack level is used when the table reference instruction is used. the program memory addresses that can be referenced by the table are all the addresses from 0000h to 0fffh of the program memory. 9.2.3 peripheral hardware control instructions (?ut? ?et? the operations of the ?ut?and ?et?instructions are as follows: (1) get dbf, p this instruction reads the data of the peripheral register addressed by p to the data buffer. (2) put p, dbf this instruction sets the data of the data buffer to the peripheral register addressed by p. 9.3 peripheral hardware and data buffer list table 9-1 lists the peripheral hardware units and the functions of the data buffer.
pd17012, 17p012 72 data sheet u10101ej4v0ds table 9-1. relationship between peripheral hardware and data buffer (1/2) peripheral hardware peripheral register that transfers data with data buffer name symbol peripheral execution of address put/get instruction a/d converter a/d converter data register adcr 02h put/get serial interface presettable shift register sio1sfr 03h put/get d/a converter pwm 0 pin pwm data register 0 pwmr0 04h put/get (pwm output) pwm 1 pin pwm data register 1 pwmr1 05h address register (ar) address register ar 40h put/get pll frequency synthesizer pll data register pllr 41h put/get key source controller/decoder key source data register ksr 42h put/get port ya port ya group register pya 42h put/get frequency counter if counter data register ifc 43h get 12-bit timer timer modulo timer modulo register tmm 46h put/get timer counter timer counter tmc 47h get peripheral hardware function number of i/o number of bits outline bits of data buffer a/d converter 8 6 sets compare voltage v ref data of a/d converter x 0.5 v ref = v dd , 1 x 63 64 serial interface 8 8 sets serial out data and reads serial in data. d/a converter 8 8 sets compare voltage v ref data of (pwm output) a/d converter x + 0.25 duty d = 100%, 0 x 255 256 frequency f = 4.3945 khz address register (ar) 16 13 transfers data with address register. pll frequency synthesizer 16 16 sets division ratio (n value) of pll. key source controller/decoder 16 16 sets output data of key source signal. port ya 16 16 sets output data of port ya 0: low level 1: high level frequency counter 16 16 reads count value of frequency counter. 12-bit timer timer modulo 16 12 sets reference data of timer modulo. timer counter 16 12 read data of up-counter ----------------------------------------------------------------------------------------------------- table 9-1. relationship between peripheral hardware and data buffer (2/2)
pd17012, 17p012 73 data sheet u10101ej4v0ds 9.4 notes on using data buffer note the following points (1) through (3) concerning unused peripheral address and write-only peripheral registers (put only) and read-only peripheral registers (get only) when transferring data with the peripheral hardware units via the data buffer. (1) when a write-only register is read, an undefined value is read. (2) nothing is changed even if data is written to a read-only register. (3) an undefined value is read if an unused register is read. nothing is changed even if data is written to an unused register.
pd17012, 17p012 74 data sheet u10101ej4v0ds 10. general-purpose ports the general-purpose ports output a high-level, low-level, or floating signal to an external circuit, and read a high-level or low-level signal from the external circuit. 10.1 configuration and classification of general-purpose ports figure 10-1 shows the block diagram of the general-purpose ports. table 10-1 classifies the general-purpose ports. as shown in figure 10-1, the general-purpose ports include ports 0a (p0a) to 1d (p1d) to which are set by addresses 70h to 73h (port registers) of each bank of the data memory, ports 2e (p2e) to 2h (p2h) to which data are set by addresses 5ch to 5fh of bank 2 of the data memory, and port ya (pya) to which data is set via a data buffer (dbf). each port consists of general-purpose port pins (e.g., port 0a consists of the p0a 2 to p0a 0 pins). as shown in table 10-1, the general-purpose ports are classified into input/output ports (i/o ports), input- only ports (input ports), and output-only ports (output ports). the i/o ports are further subdivided into bit i/o ports that can be set in the input or output mode in 1-bit units (1-pin units) and group i/o ports that can be set in the input or output mode in 4-bit units (4-pin units). figure 10-1. block diagram of general-purpose port out system register bank2 5c 5d 5e 5f bank1 bank0 dbf data memory column address peripheral address 42h bit i/o bit i/o in bit i/o in out out group i/o 0 1 2 3 4 5 6 7 out out out out pin configuration example of p0a i/o setting port register data setting control register 0123456789abcdef out row address p 0 a p 0 b p 0 c p 0 d p 1 a p 2 e p 2 f p 2 g p 2 h p y a p 1 b p 1 c p 1 d ??? ? ? p 0 a 2 pin p 0 a 1 pin p 0 a 0 pin
pd17012, 17p012 75 data sheet u10101ej4v0ds table 10-1. classification of general-purpose ports classification of general-purpose ports port data set by: general-purpose ports i/o dedicated bit i/o port 0a port register ports port 0b port 1a group i/o port 1d port register input dedicated port port 0d port register port 1b output dedicated port port 0c port register port 1c port 2e port register port 2f (multiplexed with lcd segment register) port 2g port 2h port ya peripheral register 10.2 functional outline of general-purpose ports the general-purpose output ports and the general-purpose i/o ports set in the output mode output a high or low level from the corresponding pins when data is set to the corresponding port register or port group register. the general-purpose input ports and the general-purpose i/o ports set in the input mode detect the level of the signals input to the corresponding pins by reading the contents of the corresponding port register. the general-purpose i/o ports are set in the input or output mode by the corresponding control register. in other words, these ports can be set in the input or output mode by program. p0a to p0d and p1a to p1d are set in the general-purpose port mode on power-on reset. p2e to p2h and pya are used as lcd segment signal output pins on power-on reset. to use these ports as general-purpose output ports, the corresponding control registers must be set independently. the following subsections 10.2.1 to 10.2.4 explain the port registers, the function of the port group register, and the functional outline of each port.
pd17012, 17p012 76 data sheet u10101ej4v0ds 10.2.1 general-purpose port data register (port register) a port register sets the output data and reads the input data of the corresponding general-purpose port. because the port registers are mapped in the data memory, they can be manipulated by any data memory manipulation instruction. figure 10-2 shows the relationship between a port register and the corresponding port pins. by setting data to the port register corresponding to the port pins set in the general-purpose output port mode, the output of each pin is set. by reading the contents of the port register corresponding to the port pins set in the general-purpose input port mode, the input status of each pin is detected. table 10-2 shows the relationship between each port (each pin) and port register. figure 10-2. relationship between port register and pins port register n m b 3 b 2 b 1 b 0 bit significance of port register address of port register (e.g., 70h = a, 71h = b, 72h = c, 73h = d) bank of port register p of port 3 2 1 0 bank address bit p p p p reserved words are defined for the port registers by the assembler. because these reserved words are defined in flag (bit) units, the assembler-embedded macro instructions can be used. note that data memory type reserved words are not defined for the port registers. p2e to p2h are multiplexed with lcd segment signal output pins. the port registers of p2e to p2h are also multiplexed with lcd segment registers. because the lcd segment registers are also mapped in the data memory, they can be treated in the same manner as the port registers. 10.2.2 port ya (pya) group register the port ya (pya) group register sets the output data of pya. port ya functions alternately as the key source signal output pin. therefore, the pya group register is also used as the key source data register and is allocated to address 42h of the peripheral addresses. for details, refer to 10.6.7 . 10.2.3 general-purpose i/o ports (p0a, p0b, p1a, and p1d) p0a, p0b, p1a, and p1d can be set in the input or output mode by the port 0a bit i/o select register (rf address 37h), port 0b bit i/o select register (rf address 36h), port 1a bit i/o select register (rf address 35h), and port 1d group i/o select register (rf address 27h), respectively. the input/output data of the p0a, p0b, p1a, and p1d are set by port registers p0a (address 70h of bank0), p0b (address 71h of bank0), p1a (address 70h of bank1), and p1d (address 73h of bank1), respectively. refer to table 10-2 . for details, refer to 10.3 .
pd17012, 17p012 77 data sheet u10101ej4v0ds 10.2.4 general-purpose input ports (p0d and p1b) the input data of p0d and p1b is read by port registers p0d (address 73h of bank0) and p1b (address 71h of bank1), respectively. refer to table 10-2 . for details, refer to 10.4 . 10.2.5 general-purpose output ports (p0c, p1c, p2e, p2f, p2g, p2h, and pya) (1) p0c, p1c the output data of p0c and p1c is set by port registers p0c (address 72h of bank0) and p1c (address 72h of bank1). refer to table 10-2 . for details, refer to 10.5 . (2) p2e, p2f, p2g, p2h, and pya p2e, p2f, p2g, p2h, and pya usually operate as lcd segment signal output pins. to use these ports as the output ports select the port using the p2esel to p2hsel and pyasel flags of the lcd port select register and lcd mode select register. the port to be used can be selected individually using p2e to p2h and pya. the output data of p2e, p2f, p2g, and p2h can be set by the p2e register (also used as lcdd16 of the lcd segment register, address 5fh of bank2), p2f register (also used as lcdd17, address 5eh of bank2), p2g register (also used as lcdd18, address 5dh of bank2), and p2h register (also used as lcdd19, address 5ch of bank2). refer to table 10-2 . for details, refer to 10.6 .
pd17012, 17p012 78 data sheet u10101ej4v0ds table 10-2. relationship between each port (pin) and port register (1/2) pin data setting method port port register (data memory) no. symbol i/o remarks bank address symbol bit symbol (reserved word) no pin b 3 p0a3 fixed to 0 9 (10) p0a 2 b 2 p0a2 port 0a 70h p0a 10 (11) p0a 1 i/o (bit i/o) b 1 p0a1 11 (12) p0a 0 b 0 p0a0 16 (18) p0b 3 b 3 p0b3 17 (19) p0b 2 b 2 p0b2 port 0b i/o (bit i/o) 71h p0b 18 (20) p0b 1 b 1 p0b1 19 (21) p0b 0 b 0 p0b0 bank0 27 (33) p0c 3 b 3 p0c3 28 (34) p0c 2 b 2 p0c2 port 0c output 72h p0c 29 (35) p0c 1 b 1 p0c1 30 (37) p0c 0 b 0 p0c0 59 (73) p0d 3 b 3 p0d3 60 (74) p0d 2 b 2 p0d2 port 0d input 73h p0d 61 (75) p0d 1 b 1 p0d1 62 (76) p0d 0 b 0 p0d0 no pin b 3 p1a3 fixed to 0 63 (77) p1a 2 b 2 p1a2 port 1a 70h p1a 1 (80) p1a 1 i/o (bit i/o) b 1 p1a1 2 (1) p1a 0 b 0 p1a0 12 (13) p1b 3 b 3 p1b3 13 (14) p1b 2 b 2 p1b2 port 1b input 71h p1b 14 (16) p1b 1 b 1 p1b1 15 (17) p1b 0 b 0 p1b0 bank1 20 (22) p1c 3 b 3 p1c3 21 (24) p1c 2 b 2 p1c2 port 1c output 72h p1c 22 (25) p1c 1 b 1 p1c1 23 (26) p1c 0 b 0 p1c0 31 (38) p1d 3 b 3 p1d3 32 (39) p1d 2 b 2 p1d2 port 1d i/o (group i/o) 73h p1d 33 (40) p1d 1 b 1 p1d1 34 (41) p1d 0 b 0 p1d0 remark numbers in parentheses are pin numbers for 80-pin package.
pd17012, 17p012 79 data sheet u10101ej4v0ds table 10-2. relationship between each port (pin) and port register (2/2) pin data setting method port port register (data memory) port group register (peripheral register) no. symbol i/o bank address symbol bit symbol peripheral symbol bit (reserved word) address (reserved word) b 3 b 2 70h C C C C C C b 1 b 0 b 3 b 2 71h CCC CCC b 1 b 0 bank2 fixed to 0 b 3 b 2 72h CCC CCC b 1 b 0 b 3 b 2 73h CCC CCC b 1 b 0 b 3 p2e3 no pin 5fh p2e b 2 p2e2 can be used as data memory port 2e b 1 p2e1 41 (49) p2e 0 output b 0 p2e0 b 3 p2f3 no pin 5eh p2f b 2 p2f2 can be used as data memory port 2f b 1 p2f1 40 (48) p2f 0 output b 0 p2f0 bank2 b 3 p2g3 no pin 5dh p2g b 2 p2g2 can be used as data memory port 2g b 1 p2g1 39 (47) p2g 0 output b 0 p2g0 b 3 p2h3 no pin 5ch p2h b 2 p2h2 can be used as data memory port 2h b 1 p2h1 38 (46) p2h 0 output b 0 p2h0 42 (50) pya 15 b 15 43 (52) pya 14 b 14 44 (53) pya 13 b 13 port ya | | output 42h pyar | 55 (65) pya 2 b 2 56 (66) pya 1 b 1 57 (67) pya 0 b 0 remark numbers in parentheses are pin numbers for 80-pin package. (multiplexed with lcdd18) (multiplexed with lcdd16) (multiplexed with lcdd17) (multiplexed with lcdd19) (multiplexed with ksr)
pd17012, 17p012 80 data sheet u10101ej4v0ds 10.3 general-purpose i/o ports (p0a, p0b, p1a, and p1d) 10.3.1 configuration of i/o ports the following paragraphs (1) through (3) indicate the configuration of the i/o ports. (1) p0a (p0a 2 , p0a 1 , and p0a 0 pins), p0b (p0b 3 , p0b 2 , p0b 1 , and p0b 0 pins), p1a (p1a 2 , p1a 1 , and p1a 0 pins) v dd v dd i/o select flag output latch 1 0 read instruction port register (1 bit) write instruction reset (2) p1d (p1d 3 , p1d 2 , p1d 1 , and p1d 0 pins) v dd v dd i/o select flag output latch 1 0 read instruction port register (1 bit) write instruction
pd17012, 17p012 81 data sheet u10101ej4v0ds 10.3.2 using i/o ports the i/o ports are set in the input or output mode by i/o select registers p0a p0b, p1a, and p1d of the control registers. the bit i/o ports (p0a, p0b, and p1a) can be set in the input or output mode in 1-bit units, and group i/o port (p1d) can be set in the input or output mode in 4-bit units. output data can be set to a port by writing the data to the corresponding port register, and the input data of the port can be read by executing an instruction that reads the port register. 10.3.3 explains the i/o select register of each port. 10.3.4 and 10.3.5 explain how to use the input and output ports. 10.3.3 i/o port control register the port 0a bit i/o, port 0b bit i/o, port 1a bit i/o, and port 1d group i/o select registers set each pin of the p0a, p0b, p1a, and p1d in the input or output mode. the configuration and functions of these registers are shown below. (1) port 0a bit i/o select register name flag symbol b 3 b 2 b 1 b 0 address 37h read/ write 0 1 sets input or output mode of port sets p0a 0 /si 1 pin in input mode. sets p0a 0 /si 1 pin in output mode. power-on clock stop ce 00 0 0 0 0 0 0 0 0 port 0a bit i/o select register sets input or output mode of port sets p0a 1 /so 1 pin in input mode. sets p0a 1 /so 1 pin in output mode. sets input or output mode of port sets p0a 2 /sck 1 pin in input mode. sets p0a 2 /sck 1 pin in output mode. fixed to "0" 0 1 0 1 0p 0 a b i o 2 p 0 a b i o 1 p 0 a b i o 0 after reset r/w
pd17012, 17p012 82 data sheet u10101ej4v0ds (2) port 0b bit i/o select register name flag symbol b 3 b 2 b 1 b 0 address 36h read/ write 0 1 sets input or output mode of port sets p0b 0 /beep 0 pin in input mode. sets p0b 0 /beep 0 pin in output mode. power-on clock stop ce 0 0 0 0 0 0 0 0 0 0 0 0 port 0b bit i/o select register sets input or output mode of port sets p0b 1 /beep 1 pin in input mode. sets p0b 1 /beep 1 pin in output mode. sets input or output mode of port sets p0b 2 /fcg 0 pin in input mode. sets p0b 2 /fcg 0 pin in output mode. sets input or output mode of port sets p0b 3 /fcg 1 pin in input mode. sets p0b 3 /fcg 1 pin in output mode. 0 1 0 1 0 1 after reset p 0 b b i o 3 p 0 b b i o 2 p 0 b b i o 1 p 0 b b i o 0 r/w
pd17012, 17p012 83 data sheet u10101ej4v0ds (3) port 1a bit i/o select register name flag symbol b 3 b 2 b 1 b 0 address 35h read/ write 0 1 sets input or output mode of port sets p1a 0 pin in input mode. sets p1a 0 pin in output mode. power-on clock stop ce 00 0 0 0 0 0 0 0 0 port 1a bit i/o select register sets input or output mode of port sets p1a 1 pin in input mode. sets p1a 1 pin in output mode. sets input or output mode of port sets p1a 2 pin in input mode. sets p1a 2 pin in output mode. fixed to "0" 0 1 0 1 0 1 0p 1 a b i o 2 p 1 a b i o 1 p 1 a b i o 0 after reset r/w
pd17012, 17p012 84 data sheet u10101ej4v0ds (4) port 1d group i/o select register name flag symbol b 3 0 b 2 0 b 1 0 b 0 p 1 d g i o address 27h read/ write 0 1 sets input or output mode of port sets the p1d 3 to p1d 0 pins in input mode. sets the p1d 3 to p1d 0 pins in output mode. power-on clock stop ce 0000 0 0 port 1d group i/o select register fixed to 0 after reset r/w
pd17012, 17p012 85 data sheet u10101ej4v0ds 10.3.4 using i/o ports (p0a, p0b, p1a, and p1d) as input ports select the pin to be used as an input port pin by the i/o select register corresponding to each port. note that p1d can be set in the input or output mode in 4-bit units only. the pin specified as an input port pin is floated (hi-z), and waits for input of an external signal. the input data can be read by executing an instruction that reads the contents of the port register corresponding to each port, such as the skt instruction. when a high level is input to each pin, 1 is read to the corresponding port register; when a low level is input, 0 is read. if a write instruction, such as mov, is executed to the port register corresponding to the port pin specified as an input port pin, the contents of the output latch are rewritten. 10.3.5 using i/o ports (p0a, p0b, p1a, and p1d) as output ports select the pin to be used as an output port pin by the i/o select register corresponding to each port. note that p1d can be set in the input or output mode in 4-bit units only. the pin specified as an output port pin outputs the contents of the output latch. the output data can be set by executing an instruction that writes the contents of the corresponding port register to each pin, such as the mov instruction. to output a high level to each pin, write 1 to the corresponding port register; to output a low level, write 0. the port pin can also be floated when it is specified as an input port pin. when an instruction, such as skt, that reads the contents of the port register corresponding to a port specified as an output port is executed, the contents of the output latch are read. 10.3.6 status of i/o ports (p0a, p0b, p1a, and p1d) on reset (1) on power-on reset all the i/o ports are set in the input mode. because the contents of the output latch are undefined, the output latch must be initialized by program, as necessary, before setting the corresponding port in the output mode. (2) on ce reset all the i/o ports are set in the input mode. the contents of the output latch are retained. (3) on execution of clock stop instruction all the i/o ports are set in the input mode. the contents of the output latch are retained. i/o ports other than p1d prevent an increase in the current consumption due to the noise of the input buffer by using the reset signal when the clock stop instruction is executed, as explained in 10.3.1 . if p1d is floated on execution of the clock stop instruction, the current consumption may increase due to external noise. externally pull this port down or up as necessary. (4) in halt status the previous status is retained.
pd17012, 17p012 86 data sheet u10101ej4v0ds 10.4 general-purpose input ports (p0d and p1b) 10.4.1 configuration of input ports the following paragraphs (1) and (2) indicate the configuration of the input ports. (1) p0d (p0d 3 , p0d 2 , p0d 1 , and p0d 0 pins) v dd high on resistance write instruction read instruction port register (1 bit) input latch key source signal timing output reset (2) p1b (p1b 3 , p1b 2 , p1b 1 , and p1b 0 pins) v dd to frequency counter or a/d converter write instruction read instruction port register (1 bit) reset
pd17012, 17p012 87 data sheet u10101ej4v0ds 10.4.2 using input ports (p0d and p1d) the input data is read by executing an instruction, such as skt, that reads the contents of the port register corresponding to each port pin. when a high level is input to each pin, 1 is read to the corresponding port register; when a low level is input, 0 is read. nothing is changed even if a write instruction, such as mov, is executed to the port register. 10.4.3 notes on using input port (p0d) the p0d is internally pulled down when it is used as a general-purpose port. 10.4.4 status of input ports (p0d and p1b) on reset (1) on power-on reset all the input ports are specified as general-purpose input ports. (2) on ce reset all the input ports are specified as general-purpose input ports. (3) on execution of clock stop instruction all the input ports are specified as general-purpose input ports. because the reset signal is output when the clock stop instruction is executed, p1b prevents an increase in the current dissipation due to the noise of the input buffer as described in 10.4.1 . p0d is internally pulled down. (4) in halt status the previous status is retained.
pd17012, 17p012 88 data sheet u10101ej4v0ds 10.5 general-purpose output ports (p0c and p1c) 10.5.1 configuration of output ports (p0c and p1c) the following paragraphs (1) and (2) indicate the configuration of the output ports. (1) p0c (p0c 3 , p0c 2 , p0c 1 , and p0c 0 pins) output latch read instruction port register (1 bit) write instruction (2) p1c (p1c 3 , p1c 2 , p1c 1 , and p1c 0 pins) v dd output latch read instruction port register (1 bit) write instruction
pd17012, 17p012 89 data sheet u10101ej4v0ds 10.5.2 use of output ports (p0c and p1c) the output ports output the contents of the output latches. the output data is set by executing an instruction, such as mov, that writes the data to the port register corresponding to the output port. write 1 to the port register to output a high level to the corresponding port; write 0 to output a low level. note, however, that the p0c 3 , p0c 2 , p0c 1 , and p0c 0 pins are n-ch open-drain output pins and are floated when a high level is output. when an instruction, such as skt, that reads the contents of the port register is read, the contents of the output latch are read. 10.5.3 status of output ports (p0c and p1c) on reset (1) on power-on reset the contents of the output latch are output. because the contents of the output latch are undefined, an undefined value is output for a fixed period (until the output latch is initialized by program). (2) on ce reset the contents of the output latch are output. the contents of the output latch are retained and the output data is not changed on ce reset. (3) on execution of clock stop instruction the contents of the output latch are output. the contents of the output latch are retained and the output data is not changed on execution of the clock stop instruction. therefore, initialize the output latch in the program as necessary. (4) in halt status the contents of the output latch are output. the contents of the output latch are retained and the output data is not changed in the halt status.
pd17012, 17p012 90 data sheet u10101ej4v0ds 10.6 general-purpose output ports (p2e to p2h and pya) 10.6.1 configuration of output ports (p2e to p2h and pya) the configuration of the output ports is shown below. (1) p2e (p2e 0 pin) p2f (p2f 0 pin) p2g (p2g 0 pin) p2h (p2h 0 pin) v dd 1 0 lcd/port select flag segment signal timing control output latch write instruction read instruction port register (1 bit) also used as lcd segment register (2) pya (pya 15 to pya 0 ) v dd 1 0 lcd/port select flag segment signal key source timing control output latch write instruction (put) read instruction (get) lcd segment register pya group register (1 bit), also used as key source data register
pd17012, 17p012 91 data sheet u10101ej4v0ds 10.6.2 example of using output ports (p2e to p2h and pya) each pin of p0e and p0f are used as an lcd segment signal output pin on power-on reset. to use it as an output port pin, select the port to be used by the p2esel to p2hsel and pyasel flags of the lcd port select register and lcd mode select register. the port to be used can be selected by p2e to p2h and pya independently. the pins not set in the output port mode by the lcd port select register and lcd mode select register can be used as lcd segment signal output pins. the setting of p2e to p2h and pya output data is described in 10.6.3 and 10.6.4 . the configuration and functions of the lcd port select register, lcd mode select register, and port ya (pya) group register are described in 10.6.5 to 10.6.7 . 10.6.3 setting data to p2e to p2h output data is set to p2e to p2h by executing an instruction, such as mov, that writes data to the port registers corresponding to the ports. to output a high level to each port pin, write 1 to the corresponding port register; to output a low level, write 0. the contents of the output latch are read when an instruction, such as skt, that reads the contents of the port register is executed. figure 10-3 shows the relationship between the p2e to p2h port registers and lcd segment register. as shown in this figure, the lcd segment registers higher 3 bits, lcdd16 to lcdd19, can be used as a general-purpose data memory area when p2e to p2h are used. refer to figure 19-5 relationship between lcd display dots, output of each pin, and data setting registers in 14. lcd controller/driver . figure 10-3. relationship between port registers p2e to p2h and lcd segment register p2esel flag p2hsel flag lcd 16 /p2e 0 to lcd 19 /p2h 0 1 0 segment signal timing control lcdd16/p2e to lcdd19/p2h (5fh to 5ch) b 0 b 2 b 1 b 3
pd17012, 17p012 92 data sheet u10101ej4v0ds 10.6.4 pya data setting to set output data to pya, execute the write the instruction put pya, dbf to the port ya (pya) group register corresponding to each pin. when the instruction get dbf, pya, which reads the contents of a pya group register, is executed, the contents of the output latch are read. to output a high level to each pin, write 1 to the corresponding port register; to output a low level, write 0. figure 10-4. relationship between pya group register and lcd segment register 1 0 pyasel flag lcd 15 /ks 15 /pya 15 1 0 lcdd15 (60h) b 1 b 0 lcd 14 /ks 14 /pya 14 1 0 b 2 lcdd14 (61h) b 1 b 0 b 2 lcdd1 (6eh) b 1 b 0 b 2 lcdd0 (6fh) b 1 b 15 ksr pya b 14 b 0 b 1 b 0 b 2 lcd 1 /ks 1 /pya 1 lcd 0 /ks 0 /pya 0 1 0 segment/key source timing control segment/key source timing control segment/key source timing control segment/key source timing control
pd17012, 17p012 93 data sheet u10101ej4v0ds 10.6.5 configuration and functions of lcd port select register the lcd port select register specifies whether p2e, p2f, p2g, and p2h are used as lcd segment signal output pins or as general-purpose output port pins. the configuration and function of this register are illustrated below. ports 2e, 2f, 2g, and 2h can be independently set as general-purpose output ports. the pins not specified as general-purpose output port pins operate as lcd segment signal output pins. name flag symbol b 3 b 2 b 1 b 0 address 11h read/ write 0 1 selects lcd segment signal output pin or general-purpose output port lcd 16 /p2e 0 is used as lcd segment pin lcd 16 /p2e 0 is used as general-purpose output pin power-on clock stop ce 0 0 retained 0 0 0 0 0 0 lcd port select register selects lcd segment signal output pin or general-purpose output port lcd 17 /p2f 0 is used as lcd segment pin lcd 17 /p2f 0 is used as general-purpose output pin selects lcd segment signal output pin or general-purpose output port lcd 18 /p2g 0 is used as lcd segment pin lcd 18 /p2g 0 is used as general-purpose output pin selects lcd segment signal output pin or general-purpose output port lcd 19 /p2h 0 is used as lcd segment pin lcd 19 /p2h 0 is used as general-purpose output pin 0 1 0 1 0 1 after reset p 2 h s e l p 2 g s e l p 2 f s e l p 2 e s e l r/w
pd17012, 17p012 94 data sheet u10101ej4v0ds 10.6.6 configuration and function of lcd mode select register the lcd mode select register specifies whether the pya pins are used as lcd segment signal output pins or as general-purpose port pins. this register also turns on/off all the lcd displays, and outputs key source signals. the configuration and function of this register are illustrated below. the 16 pins, lcd 0 /ks 0 /pya 0 to lcd 15 /ks 15 /pya 15 , function alternately as lcd segment signal outputs and key source signal outputs. when any of these pins is set as a general-purpose output port pin, however, neither the lcd segment signal nor key source signal is output. name flag symbol b 3 b 2 b 1 b 0 address 10h read/ write 0 1 selects lcd segment output pin or general-purpose output pin uses lcd 0 /ks 0 /pya 0 to lcd 15 /ks 15 /pya 15 pins as lcd segment pins uses lcd 0 /ks 0 /pya 0 to lcd 15 /ks 15 /pya 15 pins as general-purpose output port pins power-on clock stop ce 00 0 0 0 retained 0 0 lcd mode select register turns on/off all lcd displays display off (all segment output and common output pins go low) display on sets output of key source signal key source off key source on fixed to 0 0 1 0 1 after reset p y a s e l l c d e n k s e n 0 r/w
pd17012, 17p012 95 data sheet u10101ej4v0ds 10.6.7 port ya (pya) group register the pya group register sets the output data of the pya pins (pya 0 through pya 15 ). the pya pins can set 16-bit output data all at once. the function of the pya group register is illustrated below. b 15 b 14 b 13 b 12 b 11 b 10 b 9 b 8 b 7 b 6 b 5 b 4 b 3 b 2 b 1 b 0 name peripheral register symbol pya valid data 42h sets output data of port ya port ya group register ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? lcd 0 /ks 0 /pya 0 pin lcd 1 /ks 1 /pya 1 pin lcd 2 /ks 2 /pya 2 pin lcd 3 /ks 3 /pya 3 pin lcd 4 /ks 4 /pya 4 pin lcd 5 /ks 5 /pya 5 pin lcd 6 /ks 6 /pya 6 pin lcd 7 /ks 7 /pya 7 pin lcd 8 /ks 8 /pya 8 pin lcd 9 /ks 9 /pya 9 pin lcd 10 /ks 10 /pya 10 pin lcd 11 /ks 11 /pya 11 pin lcd 12 /ks 12 /pya 12 pin lcd 13 /ks 13 /pya 13 pin lcd 14 /ks 14 /pya 14 pin lcd 15 /ks 15 /pya 15 pin low-level output high-level output 0 1 data buffer dbf3 dbf2 dbf1 dbf0 transfer data 16 get can be executed put can be executed peripheral address port ya is alternately used with key source signal output pins. therefore, the pya group register (peripheral address: 42h) is alternately used with the key source data register (peripheral address: 42h), which is to be described later. consequently, the pya group register is used to set the output data of port ya when the lcd 0 /ks 0 /pya 0 to lcd 15 / ks 15 /pya 15 pins are specified as output port pins, and key source signal output data when these pins are specified as key source signal output pins.
pd17012, 17p012 96 data sheet u10101ej4v0ds 10.6.8 status of output ports (p2e to p2h and pya) on reset (1) on power-on reset p0e and p0f are set as lcd segment signal output pins and output a low level. because the contents of the output latch are undefined, undefined data is output if these ports are set in the output mode as is. initialize the ports in the program as necessary. (2) on ce reset p0e and p0f are set as lcd segment signal output pins and output a low level. because the contents of the output latch are retained, the previous values are retained if these ports are set in the output mode as is. (3) on execution of clock stop instruction p0e and p0f are set as lcd segment signal output pins and output a low level. because the contents of the output latch are retained, the previous values are retained if these ports are set in the output mode as is. (4) in halt status the contents of the output latch are output. because the contents of the output latch are retained, the output data is not changed in the halt status.
pd17012, 17p012 97 data sheet u10101ej4v0ds 11. interrupts 11.1 outline of interrupt block figure 11-1 illustrates the interrupt block. as shown in the figure, the interrupt block temporarily stops the program currently being executed in response to an interrupt request output from any peripheral hardware unit and branches execution to an interrupt vector address. the interrupt block consists of an interrupt control block for each peripheral hardware unit, interrupt enable flip-flop that enables all the interrupts, stack pointer that is controlled when an interrupt is acknowledged, address stack register, program counter, and interrupt stack. the interrupt control block of each peripheral hardware unit consists of an interrupt request flag (irqxxx) that detects each interrupt request, interrupt enable flag (ipxxx) that enables each interrupt, and vector address generator (vag) that specifies a vector address when an interrupt is acknowledged. the peripheral hardware units that have an interrupt function are as follows: int pin (rising-edge detection) 12-bit timer basic timer 1 serial interface
pd17012, 17p012 98 data sheet u10101ej4v0ds figure 11-1. outline of interrupt block interrupt control block serial interface basic timer 1 ipsio1 flag irqsio1 flag vector address generator 01h program counter address stack register stack pointer system register interrupt stack register interrupt enable flip-flop di, ei instruction ipbtm1 flag irqbtm1 flag vector address generator 02h 12-bit timer int pin iptm flag irqtm flag vector address generator 03h ip flag irq flag vector address generator 04h
pd17012, 17p012 99 data sheet u10101ej4v0ds 11.2 interrupt control block the interrupt control block is provided for each peripheral hardware unit and detects an interrupt request, enables the interrupt, and generates a vector address when the interrupt is acknowledged. 11.2.1 configuration and function of interrupt request flag (irq ) each interrupt request flag (irq ) is set to 1 when an interrupt request is issued from the corresponding peripheral hardware unit, and is reset to 0 when the interrupt is acknowledged. it cannot be set by software. the issued state of each interrupt request can be detected by the detection of these interrupt request flags when interrupts are not enabled. also, when 1 is directly written to the interrupt request flag via a window register, it means that the interrupt request has been issued. once this flag has been set to 1, it is not reset until the corresponding interrupt is acknowledged or 0 is written via a window register. if more than one interrupt request is issued at the same time, the interrupt request flag corresponding to the interrupt that has not been acknowledged is not reset. the interrupt request flag is assigned to the register file s interrupt request register. the configuration and function of the interrupt request register are shown in figures 11-2 to 11-5. figure 11-2. configuration of interrupt request register 1 name flag symbol b 3 b 2 b 1 b 0 address 3fh read/ write 0 1 sets interrupt request issuing status of int pin interrupt request not issued interrupt request issued power-on clock stop ce 0 0 0 000 0 0 interrupt request register 1 detects status of int pin low level is input high level is input fixed to 0 0 1 i n t 00 i r q after reset bit 3: r bit 0: r/w
pd17012, 17p012 100 data sheet u10101ej4v0ds figure 11-3. configuration of interrupt request register 2 figure 11-4. configuration of interrupt request register 3 name flag symbol b 3 b 2 b 1 b 0 address 3eh read/ write 0 1 sets interrupt request issuing status of 12-bit timer interrupt request not issued interrupt request issued power-on clock stop ce 0000 0 0 interrupt request register 2 fixed to 0 after reset 00 0 i r q t m r/w name flag symbol b 3 b 2 b 1 b 0 address 3dh read/ write 0 1 sets interrupt request issuing status of basic timer 1 interrupt request not issued interrupt request issued power-on clock stop ce 0000 0 0 interrupt request register 3 fixed to 0 after reset 0 0 0i r q b t m 1 r/w
pd17012, 17p012 101 data sheet u10101ej4v0ds figure 11-5. configuration of interrupt request register 4 11.2.2 configuration and function of interrupt enable flag (ip ) each interrupt enable flag enables the interrupt of the corresponding peripheral hardware unit. so that an interrupt is acknowledged, all the following three conditions must be satisfied. the interrupt must be enabled by the corresponding interrupt enable flag. an interrupt request must be issued by the corresponding interrupt request flag. the ei instruction (that enables all the interrupts) must be executed. the interrupt enable flag is assigned to the register file s interrupt enable register. figure 11-6 shows the configuration and function of the interrupt enable register. name flag symbol b 3 b 2 b 1 b 0 address 3ch read/ write 0 1 sets interrupt request issuing status of serial interface interrupt request not issued interrupt request issued power-on clock stop ce 0000 0 0 interrupt request register 4 fixed to 0 000i r q s i o 1 after reset r/w
pd17012, 17p012 102 data sheet u10101ej4v0ds figure 11-6. configuration of interrupt enable register 11.2.3 vector address generator (vag) the vector address generator generates a branch address (vector address) of the program memory for the interrupt source acknowledged when a peripheral hardware interrupt has been acknowledged. table 11-1 shows the vector address of each interrupt source. table 11-1. vector address of each interrupt source interrupt source vector address int pin 04h 12-bit timer 03h basic timer 1 02h serial interface 01h name flag symbol b 3 b 2 b 1 b 0 address 2fh read/ write 0 1 sets interrupt enable status of int pin interrupt disabled interrupt enabled power-on clock stop ce 0 0 0 0 0 0 0 0 0 0 0 0 interrupt enable register sets interrupt enable status of 12-bit timer interrupt disabled interrupt enabled sets interrupt enable status of basic timer 1 interrupt disabled interrupt enabled sets interrupt enable status of serial interface interrupt disabled interrupt enabled 0 1 0 1 0 1 i p s i o 1 i p b t m 1 i p t m i p after reset r/w
pd17012, 17p012 103 data sheet u10101ej4v0ds 11.3 interrupt stack register 11.3.1 configuration and function of interrupt stack register figure 11-7 shows the configuration of the interrupt stack register and the system register whose contents are saved to the interrupt stack register. the interrupt stack register saves the contents of the following system registers when an interrupt is acknowledged. bank register (bank) general register pointer (rp) program status word (psword) when an interrupt is acknowledged and the contents of the above system registers are saved to the interrupt stack register, the contents of the above system registers are reset to 0. the interrupt stack can save up to 2 levels of the contents of the above system registers. therefore, up to 2 levels of multiple interrupts can be executed. the contents of the interrupt stack register are restored to the system registers when an interrupt return instruction ( reti ) is executed. figure 11-7. configuration of interrupt stack register name bit 0h 1h interrupt stack register (intsk) bank stack register pointer stack high b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 register pointer stack low status stack b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 remark : bit not saved
pd17012, 17p012 104 data sheet u10101ej4v0ds 11.3.2 interrupt stack register operation figure 11-8 illustrates the operation of the interrupt stack register. if multiple interrupts exceeding 2 levels are acknowledged, the first saved contents are discarded and therefore must be saved by program. figure 11-8. operation of interrupt stack register (a) if interrupt does not exceed 2 levels undefined undefined v dd application a undefined interrupt a undefined undefined reti (b) if interrupt exceeds 2 levels a undefined interrupt a b a interrupt b c b interrupt c b b b b reti reti 11.4 stack pointer, address stack register, program counter the address stack register saves the return address to which execution is to be returned from an interrupt processing routine. the stack pointer specifies the address of the address stack register. when an interrupt is acknowledged, therefore, the value of the stack pointer is decremented by one and the value of the program counter at that time is saved to the address stack register specified by the stack pointer. when the dedicated return instruction reti is executed after the processing of the interrupt servicing routine has been executed, the contents of the address stack register specified by the stack pointer are restored to the program counter, and the value of the stack pointer is incremented by one. for further information, also refer to 3. address stack (ask) . 11.5 interrupt enable flip-flop (inte) the interrupt enable flip-flop enables all the interrupts. when this flip-flop is set, all the interrupts are enabled. when it is reset, all the interrupts are disabled. this flip-flop is set or reset by using dedicated instructions ei (to set) and di (to reset). the ei instruction sets this flip-flop when the instruction next to the ei instruction is executed, and the di instruction resets the flip-flop while the di instruction is executed. when an interrupt is acknowledged, this flip-flop is automatically reset. nothing is affected even if the di instruction is executed in the di state, or if the ei instruction is executed in the ei state. this flip-flop is reset on power-on reset, ce reset, and on execution of the clock stop instruction.
pd17012, 17p012 105 data sheet u10101ej4v0ds 11.6 acknowledging interrupts 11.6.1 acknowledging interrupts and priority an interrupt is acknowledged in the following procedure: (1) each peripheral hardware unit outputs an interrupt request signal to the corresponding interrupt control block if a given interrupt condition is satisfied (e.g., if a rising signal is input to the int pin). (2) when the interrupt control block has received the interrupt request signal from the peripheral hardware unit, it sets the corresponding interrupt request flag (e.g., irq flag if the peripheral unit is the int pin) to 1. (3) if the interrupt enable flag corresponding to the interrupt request flag (e.g., ip flag for irq flag) is set to 1 when the interrupt request flag is set to 1, the interrupt control block outputs 1. (4) the signal output by the interrupt control block is ored with the output of the interrupt enable flip-flop, and an interrupt acknowledge signal is output. this interrupt enable flip-flop is set to 1 by the ei instruction and reset to 0 by the di instruction. if the interrupt control block outputs 1 while the interrupt enable flip-flop is 1, the interrupt is acknowledged. as shown in figure 11-1, the interrupt acknowledge signal is input to each interrupt control block when the interrupt has been acknowledged. the interrupt request flag is reset to 0 by the signal input to the interrupt control block, and a vector address corresponding to the interrupt is output. if more than one interrupt block outputs 1 at this time, the interrupt acknowledge signal is not transferred to the next stage. if more than one interrupt request is issued at the same time, therefore, the interrupts are acknowledged in the following priority order. int pin > 12-bit timer > basic timer 1 > serial interface the interrupt of an interrupt source is not acknowledged unless the corresponding interrupt enable flag is set to 1. if the interrupt enable flag is reset to 0, therefore, an interrupt with a high hardware priority can be disabled.
pd17012, 17p012 106 data sheet u10101ej4v0ds 11.6.2 timing chart for acknowledging interrupt figure 11-9 shows the timing chart illustrating acknowledging interrupts. (1) in this figure illustrates how one interrupt is acknowledged. (a) in (1) shows the case where the interrupt request flag is the last to be set to 1, and (b) in (1) shows the case where the interrupt enable flag is the last to be set to 1. in either case, the interrupt is acknowledged when each of the interrupt request flag, interrupt enable flip- flop, and interrupt enable flag are set to 1. if the last flag or flip-flop that was set to 1 satisfies the first instruction cycle of the movt dbf, @ar instruction or a given skip condition, the interrupt is acknowledged after the second instruction cycle of the movt dbf, @ar instruction or the instruction that is skipped (nop) has been executed. the interrupt enable flip-flop is set in the instruction cycle next to the one in which the ei instruction is executed. (2) in figure 11-9 illustrates how more than one interrupt is used. in this case, the interrupts are sequentially acknowledged according to the hardware priority if all the interrupt enable flags are set. the hardware priority can be changed by manipulating the interrupt enable flag by program. interrupt cycle shown in figure 11-9 is a special cycle in which the interrupt request flag is reset, a vector address is specified, and the contents of the program counter are saved after an interrupt has been acknowledged, and lasts for 4.44 s, which is equivalent to the execution time of one instruction. for details, refer to 11.7 operations after acknowledging interrupt .
pd17012, 17p012 107 data sheet u10101ej4v0ds figure 11-9. timing chart of acknowledging interrupt (1/3) (1) when one interrupt (e.g., rising of int pin) is used (a) if interrupt is not masked by interrupt enable flag (ip ) <1> if the movt instruction or a normal instruction that does not satisfies the skip condition is executed when an interrupt is acknowledged instruction ei normal instruction interrupt cycle mov wr, #0001b poke intpm1, wr inte int pin irq flag ip flag instruction cycle: 4.44 s interrupt enable period interrupt acknowledged interrupt servicing routine <2> if the movt instruction or an instruction that satisfies the skip condition is executed when an interrupt is acknowledged instruction ei interrupt cycle mov wr, #0001b poke intpm, wr inte int pin irq flag ip flag interrupt enable period interrupt acknowledged interrupt servicing routine movt dbf,@ar skip instruction
pd17012, 17p012 108 data sheet u10101ej4v0ds figure 11-9. timing chart of acknowledging interrupt (2/3) (b) if interrupt is kept pending by interrupt enable flag interrupt pending period interrupt acknowledged interrupt servicing routine instruction ei interrupt cycle mov wr, #0001b poke intpm1, wr int pin irq flag ip flag inte
pd17012, 17p012 109 data sheet u10101ej4v0ds figure 11-9. timing chart of acknowledging interrupt (3/3) (2) when two or more interrupts are used (e.g. int pin and 12-bit timer) (a) hardware priority int pin interrupt pending period int pin interrupt servicing 12-bit timer interrupt pending period int pin interrupt acknowledged 12-bit timer interrupt servicing 12-bit timer interrupt acknowledged instruction ei interrupt cycle mov wr, #0011b poke intpm1, wr inte int pin irq flag ip flag iptm flag irqtm flag 12-bit timer ei interrupt cycle (b) software priority instruction ei interrupt cycle inte int pin irq flag ip flag ei interrupt cycle 12-bit timer irqtm flag iptm flag mov wr, #0011b poke intpm1, wr mov wr, #0011b poke intpm1, wr 12-bit timer interrupt servicing 12-bit timer interrupt pending period 12-bit timer interrupt acknowledged int pin interrupt servicing int pin interrupt acknowledged int pin interrupt pending period
pd17012, 17p012 110 data sheet u10101ej4v0ds 11.7 operations after acknowledging interrupt when an interrupt has been acknowledged, the following processing is sequentially executed. (1) the interrupt enable flip-flop and the interrupt request flag corresponding to the acknowledged interrupt are reset to 0, disabling the interrupts. (2) the contents of the stack pointer are decremented by one. (3) the contents of the program counter are saved to the address stack register specified by the stack pointer. the contents saved at this time are the next program memory address that is used after the interrupt has been acknowledged. for example, if a branch instruction is executed, the contents saved are the branch destination address; if a subroutine call instruction is executed, they are the called address. because the interrupt is acknowledged after the next instruction is executed as a nop instruction if a skip condition is satisfied by a skip instruction, the saved contents are the skipped address. (4) the lower 2 bits of the bank register (bank), lower 5 bits of the general register pointer (rp), and 5 bits of the program status word (psword) are saved to the interrupt stack. (5) the contents of the vector address generator corresponding to the acknowledged interrupt are transferred to the program counter. in other words, execution branches to an interrupt servicing routine. the processing (1) through (5) above is executed in one special instruction cycle (4.44 s) in which the normal instruction is not executed. this instruction cycle is called an interrupt cycle. in other words, one instruction cycle time is necessary since an interrupt has been acknowledged until execution branches to the corresponding vector address. 11.8 restoring from interrupt servicing routine to restore execution from an interrupt servicing routine to the processing that was being performed when the interrupt occurred, a dedicated instruction, reti , is used. when the reti instruction is executed, the following processing is sequentially executed. (1) the contents of the address stack register specified by the stack pointer are saved to the program counter. (2) the contents of the interrupt stack are restored to the lower 2 bits of the bank register (bank), lower 5 bits of the general register pointer (rp), and 5 bits of the program status word (psword). (3) the contents of the stack pointer are incremented by one. the processing (1) through (3) above is executed in one instruction cycle in which the reti instruction is executed. the difference between the reti instruction and subroutine return instructions ret and retsk is only the restoring operation of the system register in (2) above.
pd17012, 17p012 111 data sheet u10101ej4v0ds 11.9 external (int pin) interrupt 11.9.1 outline of external interrupt figure 11-10 illustrates the external interrupt. as shown in the figure, the external interrupt issues an interrupt request at the rising edge of the signal input to the int pin. the int pin is a schmitt-trigger input pin to prevent malfunctioning due to noise, and does not accept a pulse less than 1 s wide. figure 11-10. outline of external interrupt edge detection block int flag int pin interrupt control block irq flag schmitt trigger ieg flag remark int: detects pin status ieg: selects interrupt edge 11.9.2 edge detection block the edge detection block sets and detects the input signal edge (rising or falling edge) and that issues the interrupt request of the int pin. the edge setting is made by the ieg flag. figure 11-11 shows the configuration and function of the interrupt edge select register.
pd17012, 17p012 112 data sheet u10101ej4v0ds figure 11-11. configuration of interrupt edge select register 1 0 (falling) (rising) 0 1 (rising) (falling) changes in ieg flag int pin status interrupt request irq flag status low level not issued retains previous status high level issued set to 1 low level issued set to 1 high level not issued retains previous status note that as soon as the interrupt request issuing edge is changed by the ieg flag, the interrupt request signal may be issued. suppose that the ieg flag is set to 1 (specifying the falling edge) and that a high level is input to the int pin, as shown in table 11-2. if the ieg flag is reset to 0 at this time, the edge detector judges that a rising edge has been input, and issues an interrupt request. table 11-2. issuing interrupt request by changing ieg flag name flag symbol b 3 b 2 b 1 b 0 address 1fh read/ write 0 1 sets input edge issuing interrupt request of int pin rising edge falling edge power-on clock stop ce 0000 0 0 interrupt edge select register fixed to 0 after reset 000i e g r/w
pd17012, 17p012 113 data sheet u10101ej4v0ds 11.9.3 interrupt control block the level of a signal input to the int pin can be detected by using the int flag. this flag is set or reset independently of interrupts; therefore, it can be used as a 1-bit general-purpose input port when the interrupt function is not used. the int flag can also be used as a general-purpose port that can detect the rising or falling edge by reading an interrupt request flag if the interrupt corresponding to the flag is not enabled. in this case, however, the interrupt request flag is not automatically reset and must be reset by program. also refer to 11.2.1 configuration and function of interrupt request flag (irqxxx) . 11.10 internal interrupt three internal interrupt sources, 12-bit timer, basic timer 1, and serial interface, are available. 11.10.1 interrupt by 12-bit timer this interrupt request is issued at fixed time intervals. for details, refer to 12. timer . 11.10.2 interrupt by basic timer 1 this interrupt request is issued at fixed time intervals. for details, refer to 12. timer . 11.10.3 interrupt by serial interface this interrupt request is issued when a serial output or serial input operation has been completed. for details, refer to 15. serial interface .
pd17012, 17p012 114 data sheet u10101ej4v0ds 12. timer the timers are used to control the program execution time. 12.1 general figure 12-1 illustrates the timers of the pd17012. as shown in this figure, the pd17012 is provided with the following three timers: ?basic timer 0 ?basic timer 1 ?12-bit timer (modulo timer) basic timer 0 is used to detect the status of a flip-flop that is set at fixed time intervals. basic timer 1 is used to issue an interrupt request at fixed time intervals. the 12-bit timer is a modulo timer that issues an interrupt request at fixed time intervals. basic timer 0 can also be used to detect a power failure. the clock of each timer is generated by dividing the system clock (4.5 mhz). figure 12-1. outline of timer (a) basic timer 0 clock select block ff btm0cy flag 4.5 mhz (b) basic timer 1 clock select block 4.5 mhz interrupt request (c) 12-bit timer interrupt request clock select block 4.5 mhz start/stop 12-bit counter match detection modulo register
pd17012, 17p012 115 data sheet u10101ej4v0ds 12.2 basic timer 0 12.2.1 outline of basic timer 0 figure 12-2 illustrates basic timer 0. basic timer 0 is used as a timer by detecting the status of a flip-flop that is set at fixed intervals (100, 250, 5, or 1 ms), using the btm0cy flag (rf: address 17h, bit 0). the contents of the flip-flop correspond to the btm0cy flag. if the btm0cy flag is read first after power-on reset, 0 is always read. after that, the flag is set to 1 at fixed intervals. if the ce pin goes high from low, ce reset is effected in synchronization with the timing at which the btm0cy flag is set next. therefore, a power failure can be detected by reading the contents of the btm0cy flag at system reset (power-on reset or ce reset). for details of power failure detection, refer to 22. reset . figure 12-2. outline of basic timer 0 divider clock select block 4.5 mhz btm0cy flag selector btm0ck0 flag btm0ck1 flag flip-flop remarks 1. btm0ck1 and btm0ck0 (bits 1 and 0 of the basic timer clock select register: refer to figure 12-3 ) set the time intervals at which the btm0cy flag is set. 2. btm0cy (bit 0 of the basic timer 0 carry ff judge register: refer to figure 12-4 ) detects the status of the flip-flop.
pd17012, 17p012 116 data sheet u10101ej4v0ds 12.2.2 clock select block the clock select block divides the system clock (4.5 mhz) and sets the time interval at which the btm0cy flag is to be set, by using the basic timer clock select register. figure 12-3 shows the configuration of the basic timer clock select register. figure 12-3. configuration of basic timer clock select register note for basic timer 1, refer to 12.3 . name flag symbol b 3 b t m 1 c k 1 b 2 b t m 1 c k 0 b 1 b t m 0 c k 1 b 0 b t m 0 c k 0 address 09h read/ write basic timer clock select register power-on clock stop ce after reset 0 1 0 1 0 0 100 ms (10 hz) 250 ms (4 hz) 5 ms (200 hz) 1 ms (1 khz) sets time interval at which btm0cy flag is set 0 0 0 0 0 0 1 1 0 0 retained 0 1 0 1 100 ms (10 hz) 250 ms (4 hz) 5 ms (200 hz) 1 ms (1 khz) sets time interval at which irqbtm1 flag is set note 0 0 1 1 r/w
pd17012, 17p012 117 data sheet u10101ej4v0ds 12.2.3 flip-flop and btm0cy flag the flip-flop is set at fixed intervals and its status is detected by the btm0cy flag of the basic timer 0 carry ff judge register. when the btm0cy flag reads out its contents to the window register by peek instruction execution, it is reset to 0 (read & reset). the btm0cy flag is 0 at power-on reset, and is 1 at ce reset and on execution of the clock stop instruction. therefore, this flag can be used to detect a power failure. the btm0cy flag is not set after power application until an instruction that reads it is executed. once the read instruction has been executed, the flag is set at fixed intervals. figure 12-4 shows the configuration of the basic timer 0 carry ff judge register. figure 12-4. configuration of basic timer 0 carry ff judge register name flag symbol b 3 0 b 2 0 b 1 0 b 0 b t m 0 c y address 17h read/ write basic timer 0 carry ff judge register power-on clock stop ce after reset 0 1 0 1 1 flip-flop is not set flip-flop is set fixed to 0 detects status of flip-flop 000 r & reset
pd17012, 17p012 118 data sheet u10101ej4v0ds 12.2.4 example of using basic timer 0 an example of a program using basic timer 0 is shown below. this program executes processing a every 1 second. example clr2 btm0ck1, btm0ck0 ; sets btm0cy flag setting pulse to 10 hz (100 ms) mov m1, #0 loop: skt1 btm0cy ; branches to next if btm0cy flag is 0 br next add m1, #1 ; adds 1 to m1 ske m1, #0ah ; executes processing a if m1 is 10 (1 second has elapsed) br next mov m1, #0 processing a next: processing b ; executes processing b and branches to loop br loop
pd17012, 17p012 119 data sheet u10101ej4v0ds 12.2.5 errors of basic timer 0 errors of basic timer 0 include an error due to the detection time of the btm0cy flag, and an error that occurs when the time interval at which the btm0cy flag is to be set is changed. the following paragraphs (1) and (2) describe each error. (1) error due to detection time of btm0cy flag the time to detect the btm0cy flag must be shorter than the time at which the btm0cy flag is set (refer to 12.2.6 notes on using basic timer 0 ). where the time interval at which the btm0cy flag is detected is t check and the time interval at which the flag is set is t set (250, 10, 5, or 1 ms), t check and t set must relate as follows. t check < t set at this time, the error of the timer when the btm0cy flag is detected is as follows, as shown in figure 12-5. 0 < error < t set figure 12-5. error of basic timer 0 due to detection time of btm0cy flag h l btm0cy flag setting pulse t set t check1 skt1 btm0cy <1> skt1 btm0cy <2> skt1 btm0cy <3> skt1 btm0cy <4> t check2 t check3 1 0 btm0cy flag as shown in figure 12-5, the timer is updated because btm0cy flag is 1 when it is detected in step <2>. when the flag is detected next in step <3>, it is 0. therefore, the timer is not updated until the flag is detected again in <4>. this means that the timer is extended by the time of t check3 .
pd17012, 17p012 120 data sheet u10101ej4v0ds (2) error when time interval to set btm0cy flag is changed the btm0ck1 and btm0ck0 flags set the time of the btm0cy flag. as described in 12.2.2 , four types of timer time-setting pulses can be selected: 1 khz, 200 hz, 10 hz, and 4 hz. at this time, these four pulses operate independently. if the timer time-setting pulse is changed by using the btm0ck1 and btm0ck0 flags, an error occurs as described in the example below. example ; <1> intiflg btm0ck1, not btm0ck0 ; sets btm0cy flag setting pulse to 200 hz (5 ms) processing a ; <2> initflg btm0ck1, btm0ck0 ; sets btm0cy flag setting pulse to 1 khz (1 ms) processing a ; <3> initflg btm0ck1, not btm0ck0 ; sets btm0cy flag setting pulse to 200 hz (5 ms) at this time, the btm0cy flag setting pulse is changed as shown in figure 12-6. figure 12-6. changing btm0cy flag setting pulse h l internal pulse 200 hz internal pulse 1 khz h l btm0cy flag 1 0 btm0cy flag setting pulse h l skt1 btm0cy <2> <3> <1> as shown in figure 12-6, if the btm0cy flag setting time is changed and the new pulse falls, the btm0cy flag retains the previous status (<2> in the figure). if the new pulse rises, however, the btm0cy flag is set to 1 (<3> in the figure). although changing the pulse setting between 200 hz (5 ms) and 1 khz (1 ms) is described in this example, the same applies to changing the pulse in respect to 4 hz (250 ms) and 10 hz (100 ms).
pd17012, 17p012 121 data sheet u10101ej4v0ds therefore, as shown in figure 12-7, the error of the time until the btm0cy flag is first set after the btm0cy flag setting time has been changed is as follows: t set < error < t check t set : new setting time of btm0cy flag t check : time to detect btm0cy flag phase differences are provided among the internal pules of 4, 10, 200 hz, and 1 khz. because these phase differences are shorter than the newly set pulse time, they are included in the above error. for the phase difference of each pulse, refer to 12.3.5 notes on using basic timer 1 . figure 12-7. timer error when btm0cy flag setting time is changed from a to b (a) ? t set difference (b) t check difference h l h l h l h l t set skt1 btm0cy intrinsic timer time actual timer time time changed internal pulse a internal pulse b btm0cy flag setting pulse btm0cy flag t set t check actual timer time intrinsic timer time time changed an error of t check occurs if the timer time is changed immediately after the btm0cy flag has been detected because the flag is then reset once. an error of -t set occurs if the btm0cy flag is detected immediately after the timer time has been changed because the flag then becomes 1 . a = 0 a . . a = 0 a . .
pd17012, 17p012 122 data sheet u10101ej4v0ds 12.2.6 cautions on using basic timer 0 (1) btm0cy flag detection time interval keep the time to detect the btm0cy flag shorter than the time at which the btm0cy flag is set. this is because if the time of processing b is longer than the time interval at which the btm0cy flag is set as shown in figure 12-8, setting of the btm0cy flag is overlooked. figure 12-8. btm0cy flag detection and btm0cy flag h btm0cy flag setting pulse btm0cy flag l skt1 btm0cy skt1 btm0cy processing a processing b skt1 btm0cy t set <1> <2> <3> <4> <5> 1 0 because execution time of processing b takes too long after detection of btm0cy flag that has been set to 1 in <2>, the btm0cy flag that is set to 1 in <3> cannot be detected. (2) timer updating processing time and btm0cy flag detection time interval as described in (1) above, time interval t set at which the btm0cy flag is detected must be shorter than the time for which to set the btm0cy flag. at this time, even if the time interval at which the btm0cy flag is detected is short, if the updating processing time of the timer is long the processing of the timer may not be executed normally at ce reset. therefore, the following condition must be satisfied. t check + t timer < t set t check : time to detect btm0cy flag t timer : timer updating processing time t set : time to set btm0cy flag an example is given below.
pd17012, 17p012 123 data sheet u10101ej4v0ds example example of timer updating processing and btm0cy flag detection time interval start: clr2 btm0ck1, btm0ck0 ; sets btm0cy flag setting pulse to 10 hz (100 ms) btimer: ; <1> skt1 btm0cy ; updates timer if btm0cy flag is ? br aaa ; branches to aaa if btm0cy flag is ? timer updating br btimer aaa: processing a br btimer the timing chart of the above program is shown below. t set h ce pin btm0cy detection interval t check timer updating processing t timer btm0cy flag btm0cy flag setting pulse l h l 1 <1> skt1 btm0cy <2> skt1 btm0cy ce reset 0 if this timer updating processing time is too long, ce reset is effected during processing. (3) correcting basic timer 0 carry at ce reset next, an example of correcting the timer at ce reset is described below. as shown in the example below, the timer must be corrected at ce reset if the btm0cy flag is used for power failure detection and if the btm0cy flag is used for a watch timer. the btm0cy flag is reset (to 0) first on power application (power-on reset), and is disabled from being set until it is read once by the peek instruction. if the ce pin goes high from low, a ce reset is effected in synchronization with the rising edge of the btm0cy flag setting pulse. at this time, the btm0cy flag is set (to 1) and the timer is started. by detecting the status of the btm0cy flag at system reset (power-on reset or ce reset), therefore, it can be identified whether a power-on reset or ce reset has been effected (power failure detection). that is, a power-on reset has been effected if the flag is 0, and a ce reset has been effected if it is 1. at this time, the watch timer must continue operating even if a ce reset has been effected. however, because the btm0cy flag is reset to 0 when it is read to detect a power failure, the set status (1) of the btm0cy flag is overlooked once. consequently, the watch timer must be updated if a ce reset is identified by means of power failure detection. for details of power failure detection, refer to 22. reset .
pd17012, 17p012 124 data sheet u10101ej4v0ds example example of correcting timer at ce reset (to detect power failure and update watch timer using btm0cy flag) start: ; program address 0000h processing a ; <1> skt1 btm0cy ; embedded macro ; tests btm0cy flag br initial ; if 0 , branches to initial (power failure detection) backup: ; <2> 100 ms watch updating ; corrects watch timer because of backup (ce reset) loop: ; <3> processing b : while performing processing b, skf1 btm0cy ; tests btm0cy flag and updates watch timer br backup br loop initial: clr2 btm0ck1, btm0ck0 ; embedded macro ; because power failure (power-on reset) occurs, ; sets setting time of btm0cy flag to 100 ms, and ; executes processing c processing c br loop figure 12-9 shows the timing chart of the above program.
pd17012, 17p012 125 data sheet u10101ej4v0ds figure 12-9. timing chart a power-on reset start from address 0 ce reset start from address 0 application of supply voltage btm0cy flag detected c 5 v v dd ce btm0cy flag setting pulse (10 hz) btm0cy flag program processing program instruction 0 v h l h l 1 0 bb b b b bbb bb <3> watch up <3> watch up <3> watch up <3> <3> <1> watch up <3> <3> <3> <3> <3> <1> a updates watch timer because setting of btm0cy flag (to 1) is detected point a point b point c point d point e as shown in figure 12-9, the program is started from address 0000h because the internal 10-hz pulse rises when supply voltage v dd is first applied. when the btm0cy flag is detected at point a, it is judged that the btm0cy flag is reset (to 0) and that a power failure (power-on reset) has occurred because the power has just been applied. therefore, processing c is executed, and the btm0cy flag setting pulse is set to 100 ms. because the content of the btm0cy flag is read once at point a, the btm0cy flag will be set to 1 every 100 ms. next, even if the ce pin goes low at point b and high at point c, the program counts up the watch timer while executing processing b , unless the clock stop instruction is executed. at point c, because the ce pin goes high from low, ce reset is effected at point d at which the btm0cy flag setting pulse rises next time, and the program is started from address 0000h. when the btm0cy flag is detected at point e at this time, it is set to 1. therefore, this is judged to be a back up (ce reset). as is evident from the above figure, unless the watch is updated by 100 ms at point e, the watch is delayed by 100 ms each time ce reset is effected. if processing a takes longer than 100 ms when a power failure is detected at point e, the setting of the btm0cy flag is overlooked two times. therefore, processing a must be completed within 100 ms. the above description also applies when the btm0cy flag setting pulse is set to 250, 5, or 1 ms. therefore, the btm0cy flag must be detected for power failure detection within the btm0cy flag setting time after the program has been started from address 0000h.
pd17012, 17p012 126 data sheet u10101ej4v0ds (4) if btm0cy flag is detected at the same time as ce reset as described in (3) above, ce reset is effected as soon as the btm0cy flag is set to 1. if the instruction that reads the btm0cy flag happens to be executed at the same time as ce reset at this time, the btm0cy flag reading instruction takes precedence. therefore, if the next setting the btm0cy flag (rising of btm0cy flag setting pulse) after the ce pin has gone high coincides with execution of the btm0cy flag reading instruction, ce reset is effected at the next timing at which the btm0cy flag is set. this operation is illustrated in figure 12-10. figure 12-10. operation when ce reset coincides with btm0cy flag reading instruction h btm0cy flag setting pulse btm0cy flag ce pin l h l 4.44 s skt1 btm0cy (peek ) skt1 btm0cy ce reset (skt ) 1 0 h btm0cy flag setting pulse btm0cy flag instruction embedded macro peek wr, . mf. btm0cy shr 4 skt wr, #. df. btm0cy and 000fh l 1 0 if btm0cy flag is read at this time, ce reset is effected delayed once. originally, program is started from address 0000h here. however, ce reset is not effected because it happens to coincide with program that reads btm0cy flag. skt1 btm0cy consequently, if the btm0cy flag detection time interval coincides with the btm0cy flag setting time in a program that cyclically detects the btm0cy flag, ce reset is never effected. therefore, the following point must be noted. because one instruction cycle is 4.44 s (1/225 khz), a program that detects the btm0cy flag once, for example, every 225 instructions, reads the btm0cy flag every 4.44 s 225 = 1 ms. even if any of 1 ms, 5 ms, 100ms, or 250 ms is selected as the timer time setting pulse, if setting and detection of the btm0cy flag coincide once, ce reset is never effected.
pd17012, 17p012 127 data sheet u10101ej4v0ds therefore, do not create a cyclic program that satisfies the following condition. t set 225 = n (n: natural number) x t set : btm0cy flag setting time x: cycle x step of instruction that reads btm0cy flag an example of a program that satisfies the above condition is shown below. do not create such a program. example processing a set btm0ck1, btm0ck0 ; embedded macro ; sets btm0cy flag setting pulse to 1 ms loop: ; <1> skt1 btm0cy ; embedded macro br bbb aaa: 221 steps br loop bbb: 221 steps br loop because the btm0cy flag reading instruction in <1> is repeatedly executed every 225 instructions in this example, ce reset is not effected if the btm0cy flag happens to be set at the timing of the instruction in <1>.
pd17012, 17p012 128 data sheet u10101ej4v0ds 12.3 basic timer 1 12.3.1 general figure 12-11 illustrates basic timer 1. basic timer 1 issues an interrupt request at a fixed time interval and sets the irqbtm1 flag to 1. the interrupt generated by basic timer 1 is acknowledged when the irqbtm1 flag is set, if the ei instruction has been issued and the ipbtm1 flag has been set (refer to 11. interrupts ). figure 12-11. outline of basic timer 1 btm1ck1 flag btm1ck0 flag clock select block irqbtm1 set signal divider selector 4.5 mhz remark btm1ck1 and btm1ck0 (bits 3 and 2 of the basic timer clock select register, refer to figure 12-3 ) set the time interval at which the irqbtm1 flag is set. 12.3.2 clock select block the clock select block divides the system clock (4.5 mhz) and sets the time interval at which the irqbtm1 flag is to be set, by using the basic timer clock select register. for the configuration and function of the basic timer clock select register, refer to figure 12-3.
pd17012, 17p012 129 data sheet u10101ej4v0ds 12.3.3 application example of basic timer 1 a program example is shown below. example m1 mem 0.10h ; 80 ms counter btimer1 dat 0002h ; symbol definition of basic timer 1 interrupt vector address br start ; branches to start org btimer1 ; program address (0002h) add m1, #0001b ; adds 1 to m1 skt1 cy ; tests cy flag br ei_reti ; returns if no carry processing a ei_reti: ei reti start: initflg btm1ck1, not btm1ck0 ; embedded macro ; sets basic timer 1 interrupt pulse to 5 ms mov m1, #0000b ; clears contents of m1 to 0 set1 ipbtm1 ; enables basic timer 1 interrupt ei ; enables all interrupts loop: processing b br loop this program executes processing a every 80 ms. the points to be noted in this case are that the di status is automatically set when an interrupt has been acknowledged, and that the irqbtm1 flag is set to 1 even in the di status. this means that the interrupt is acknowledged even if execution exits from an interrupt routine by execution of the reti instruction, if processing a takes longer than 5 ms. consequently, processing b is not executed.
pd17012, 17p012 130 data sheet u10101ej4v0ds 12.3.4 error of basic timer 1 as described in 12.3.3 , the interrupt generated by basic timer 1 is acknowledged each time the basic timer 1 interrupt pulse falls, if the ei instruction has been executed, and if the interrupt has been enabled. therefore, an error of basic timer 1 occurs only when any of the following operations (1) to (3) is performed: (1) when the first interrupt after the basic timer 1 interrupt has been enabled has been acknowledged (2) when the time interval at which the irqbtm1 flag is to be set is changed, i.e., when the first interrupt is acknowledged after the interrupt pulse has been changed (3) when data has been written to the irqbtm1 flag figure 12-12 shows an error in each of the above operations. figure 12-12. error of basic timer 1 (1/2) (a) when interrupt by basic timer 1 is enabled ei ei ei interrupt pending <1> <3> <2> t set set1 ipbtm1 interrupt acknowledged interrupt acknowledged interrupt acknowledged basic timer 1 interrupt pulse irqbtm1 flag ipbtm1 flag inte ff h l 1 0 1 0 ei di at point <1> in the above figure, the interrupt by basic timer 1 is acknowledged as soon as the interrupt is enabled. at this time, the error is t set . if an interrupt is enabled by the ei instruction at the next point <2> , the interrupt occurs at the falling edge of the basic timer 1 interrupt pulse. at this time, the error is: t set < error < 0
pd17012, 17p012 131 data sheet u10101ej4v0ds figure 12-12. error of basic timer 1 (2/2) (b) when basic timer 1 interrupt pulse is changed ei ei ei ei interrupt acknowledged interrupt acknowledged <1> basic timer 1 interrupt pulse changed <3> basic timer 1 interrupt pulse changed <2> interrupt acknowledged internal pulse a internal pulse b basic timer 1 interrupt pulse irqbtm1 flag ipbtm1 flag inte ff h l h l h l 1 0 1 0 ei di even if the basic timer 1 interrupt pulse is changed to b at point <1> in the above figure, the interrupt is acknowledged at the next point <2> because the basic timer 1 interrupt pulse does not fall. if the basic timer 1 interrupt pulse is changed to a at <3> , the interrupt is immediately acknowledged because the basic timer 1 interrupt pulse falls. (c) when irqbtm1 flag is manipulated ei ei ei interrupt acknowledged interrupt acknowledged <1> set1 irqbtm1 interrupt acknowledged <2> clr1 irqbtm1 interrupt not acknowledged basic timer 1 interrupt pulse irqbtm1 flag ipbtm1 flag inte ff h l 1 0 1 0 ei di the interrupt is immediately acknowledged if the irqbtm1 flag is set to 1 at <1> . if clearing the irqbtm1 flag to 0 overlaps with the falling of the basic timer 1 interrupt pulse at <2> , the interrupt is not acknowledged.
pd17012, 17p012 132 data sheet u10101ej4v0ds 12.3.5 notes on using basic timer 1 when creating a program, such as a watch program, in which processing is always performed at fixed time intervals using basic timer 1 after the supply voltage has been applied (power-on reset), the basic timer 1 interrupt servicing must be completed in a fixed time. let s take the following example: example m1 mem 0.10h ; 1 ms counter btimer1 dat 0002h ; symbol definition of interrupt vector address of basic timer 1 br start ; branches to start org btimer1 ; program address (0002h) add m1, #0100b ; adds 0100b to m1 skt1 cy ; watch processing if carry occurs br ei_reti ; returns if no carry occurs ; <1> watch processing ei_reti: ei reti start: initflg not btm1ck1, btm1ck0, not btm0ck1, not btm0ck0 ; embedded macro ; sets time of interrupt by basic timer 1 to 250 ms ; and set time of btm0cy flag to 100 ms set1 ipbtm1 ; embedded macro ; enables interrupt by basic timer 1 ei ; enables all interrupts loop: processing a br loop in this example, watch processing <1> is executed every 1 second while processing a is executed. if the ce pin goes high as shown in figure 12-13 (a), ce reset is effected in synchronization with the rising of the btm0cy flag setting pulse. if issuance of an interrupt request by the basic timer 1 happens to overlap with the setting of the btm0cy flag at this time, ce reset takes precedence. when ce reset is effected, the basic timer 1 interrupt request (irqbtm1) flag is cleared. consequently, the timer processing is skipped once.
pd17012, 17p012 133 data sheet u10101ej4v0ds to prevent this, a delay is actually provided to the rising of the btm0cy flag setting pulse and falling of the basic timer 1 interrupt pulse as shown in figure 12-13 (b). in the above example, therefore, skipping of the basic timer 1 interrupt is prevented, even if a ce reset is effected, by performing the watch processing within 10 ms. because the btm0cy flag setting pulse and basic timer 1 interrupt time setting pulse can be independently set to 4 hz (250 ms), 10 hz (100 ms), 200 hz (5 ms), or 1 khz (1 ms), a time difference is provided as shown in figure 12-14 and table 12-1. consequently, if the basic timer 1 interrupt must be enabled even when a ce reset is effected, the servicing of the basic timer 1 interrupt must be completed within the delay time of the pulse shown in figure 12-14. figure 12-13. timing chart (a) basic timer 1 interrupt because the btm0cy flag setting pulse rises, a ce reset is effected here. as a result, the basic timer 1 interrupt is skipped once. h l h l h l ce pin btm0cy flag setting pulse basic timer 1 interrupt pulse (b) delay time: 10 ms in this case basic timer 1 interrupt basic timer 1 interrupt ce reset because there is a delay of 10 ms between the falling of the basic timer 1 interrupt pulse and the rising of the btm0cy flag setting pulse, if basic timer 1 interrupt servicing is completed within 10 ms, the timer processing is executed normally, even if a ce reset is effected. h l h l h l ce pin btm0cy flag setting pulse basic timer 1 interrupt pulse
pd17012, 17p012 134 data sheet u10101ej4v0ds figure 12-14. time difference between btm0cy flag setting pulse and basic timer 1 interrupt pulse 2 : 1 : 1 10 ms 1 ms 1 ms btm0cy 5 ms btm0cy 1 ms int 5 ms int 100 ms btm0cy dummy 250 ms btm0cy 100 ms int 250 ms int
pd17012, 17p012 135 data sheet u10101ej4v0ds table 12-1. time difference between rising edge of btm0cy flag setting pulse and falling edge of basic timer 1 interrupt pulse internal pulse minimum value of time difference (refer to figure below.) btm0cy flag setting pulse basic timer 1 interrupt pulse t 1 t 2 1 ms 1 ms 666 s 333 s 1 ms 5 ms 333 s 666 s 1 ms 100 ms 333 s 666 s 1 ms 250 ms 333 s 666 s 5 ms 1 ms 333 s 666 s 5 ms 5 ms 3 ms 2 ms 5 ms 100 ms 2 ms 3 ms 5 ms 250 ms 2 ms 3 ms 100 ms 1 ms 333 s 666 s 100 ms 5 ms 1 ms 4 ms 100 ms 100 ms 50 ms 50 ms 100 ms 250 ms 10 ms 40 ms 250 ms 1 ms 333 s 666 s 250 ms 5 ms 1 ms 4 ms 250 ms 100 ms 40 ms 10 ms 250 ms 250 ms 100 ms 150 ms t 1 h l h l t 2 btm0cy flag setting pulse basic timer 1 interrupt pulse
pd17012, 17p012 136 data sheet u10101ej4v0ds 12.4 12-bit timer 12.4.1 general figure 12-15 illustrates the 12-bit timer. the 12-bit timer operates as a timer by counting the basic clock (100 khz or 20 khz) by using a 12-bit counter, and comparing its count value with a value set in advance. figure 12-15. outline of 12-bit timer divider 4.5 mhz selector tmck flag tmrpt flag tmen flag match overflow dbf tmovf flag dbf timer/counter (tmc) timer modulo register (tmm) match detector 12 12 tmres flag clock select block count block irqtm set signal set remarks 1. tmck (bit 0 of 12-bit timer clock select register; refer to figure 12-16 ) sets the basic clock frequency. 2. tmen (bit 0 of 12-bit timer control register; refer to figure 12-17 ) starts/stops the 12-bit timer. 3. tmres (bit 1 of 12-bit timer control register; refer to figure 12-17 ) controls resetting the timer/counter. 4. tmrpt (bit 2 of 12-bit timer control register; refer to figure 12-17 ) selects the modulo count mode/free- run count mode. 5. tmovf (bit 0 of 12-bit timer overflow register; refer to figure 12-18) detects an overflow in the timer/ counter.
pd17012, 17p012 137 data sheet u10101ej4v0ds 12.4.2 clock select block the clock select block selects the basic clock that is used for the operation of the timer/counter. two basic clocks can be selected by using the tmck flag. figure 12-16 shows the configuration and function of the 12-bit timer clock select register. figure 12-16. configuration of 12-bit timer clock select register divider 4.5 mhz selector tmck flag tmrpt flag tmen flag match overflow dbf tmovf flag dbf timer/counter (tmc) timer modulo register (tmm) match detector 12 12 tmres flag clock select block count block irqtm set signal set remark r: retained
pd17012, 17p012 138 data sheet u10101ej4v0ds 12.4.3 count block the count block counts the basic clock by using a 12-bit timer/counter. when the count value matches the value of the timer modulo register, the count block issues an interrupt request. the value of the timer/counter can be written or read via the data buffer. the basic clock that is input to the timer/counter can be started or stopped by the tmen flag. the timer/counter can be reset by the tmres flag. the timer/counter is not automatically reset even when its count value matches the value of the timer modulo register. either the modulo count mode or free-run count mode can be set by the tmrpt flag. in the free-run count mode, the contents of the timer/counter are not reset even after a match between the value of the timer/counter and the contents of the timer modulo register has been detected; therefore, the timer/counter continues counting up. in the modulo counter mode, the contents of the timer/counter are reset and then the timer/counter continues counting when a match between the count value of the timer/counter and the contents of the timer modulo register has been detected. an overflow in the counter, if any, can be detected by the tmovf flag. if an overflow has been detected, the counting operation is stopped. figure 12-17 shows the configuration and function of the 12-bit timer control register. figure 12-18 shows the configuration and function of the 12-bit timer overflow register. figures 12-19 and 12-20 show the configurations of the timer/counter and timer modulo register respectively. figure 12-17. configuration of 12-bit timer control register note the tmres flag is always 0 when it is read. name flag symbol b 3 b 2 b 1 b 0 address 0eh read/ write 0 1 starts/stops timer/counter stops starts power-on clock stop ce 00 0 0 0 retained 0 0 12-bit timer control register restarts timer/counter note does not reset resets sets mode of 12-bit timer free-run count mode modulo count mode fixed to 0 0 1 0 1 0t m r p t t m r e s t m e n after reset r/w
pd17012, 17p012 139 data sheet u10101ej4v0ds figure 12-18. configuration of 12-bit timer overflow register remark r: retained name flag symbol b 3 b 2 b 1 b 0 address 0dh read/ write 0 1 detects overflow in timer/counter overflow does not occur overflow occurs power-on clock stop ce 0000 0 r 12-bit timer overflow register fixed to 0 after reset 000t m o v f r
pd17012, 17p012 140 data sheet u10101ej4v0ds figure 12-19. configuration of timer/counter name symbol address bit data data buffer dbf3 0ch dbf2 0dh dbf1 0eh dbf0 0fh b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 transfer data 16 get b 15 b 14 b 13 b 12 b 11 b 10 b 9 b 8 b 7 b 6 b 5 b 4 b 3 b 2 b 1 b 0 name timer/ counter peripheral register symbol tmc valid data 47h measured value of timer/counter 0 | x | 2 12 ? 1 (fffh) ? in free-run count mode, counts up to fffh and stops counting at the next clock. ? in modulo count mode, counts up to the data value set in the timer modulo register, is cleared to 000h at the next clock, then continues counting. fixed to 0 m s b l s b peripheral address
pd17012, 17p012 141 data sheet u10101ej4v0ds figure 12-20. configuration of timer modulo register name symbol address bit data data buffer dbf3 0ch dbf2 0dh dbf1 0eh dbf0 0fh b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 transfer data 16 get put b 15 b 14 b 13 b 12 b 11 b 10 b 9 b 8 b 7 b 6 b 5 b 4 b 3 b 2 b 1 b 0 name peripheral register symbol tmm valid data 46h set value of timer modulo 0 1 | x | 2 12 ? 1 (fffh) setting prohibited modulo data fixed to 0 timer modulo register m s b l s b peripheral address
pd17012, 17p012 142 data sheet u10101ej4v0ds 12.4.4 application example of 12-bit timer example 1. modulo count mode tmint dat 0003h ; symbol definition of 12-bit timer interrupt vector address br start org tmint ; program address (0003h) processing a ei reti start: initflg tmck ; sets count clock to 100 khz (10 s) mov dbf2, #50 shr 8 and 0fh mov dbf1, #50 shr 4 and 0fh mov dbf0, #50 and 0fh put tmm, dbf set1 iptm ei set3 tmrpt, tmres, tmen loop: main processing br loop this program executes processing a every 500 s. however, processing a must be completed within 500 s. example 2. free-run count mode br start start: initflg tmck ; sets count clock to 100 khz (10 s) initflg not tmrpt, tmres, tmen processing a skf1 tmovf br overflow occurs get dbf, tmc overflow occurs this program is to measure the time required for processing a. the measurable time range is from 10 s to 40,950 s (the software in example 2 cannot measure time exceeding 40,950 s and therefore, execution must branch to another routine to measure the time longer than 40,950 s). this program is used to measure the pulse width of a remote controller signal. the modulo count mode is useful for issuing an interrupt request at fixed time intervals, but the free-run count mode is better to measure total time. . . . . . . . . . . .
pd17012, 17p012 143 data sheet u10101ej4v0ds 12.4.5 error of 12-bit timer the 12-bit timer produces an error of a maximum of 1 basic clock in the following cases: (1) when tmen flag is manipulated when the tmen flag is set, an error of 0 to +1 clock occurs. when the tmen flag is cleared, an error of 0 to 1 clock occurs. (2) when counter in operation is reset when the counter is reset, an error of 0 to +1 clock occurs. (3) when basic clock is changed during counter operation an error of 0 to +1 clock of the new clock occurs. 12.4.6 notes on using 12-bit timer the interrupt by the 12-bit timer may be generated at the same time as the interrupt by basic timer 1 and ce reset. if the timer must be updated even at ce reset, do not use the 12-bit timer. instead, use basic timer 1.
pd17012, 17p012 144 data sheet u10101ej4v0ds 13. a/d converter (adc) 13.1 general figure 13-1 illustrates the a/d converter. the a/d converter compares an analog voltage input to the adc 0 or adc 1 pins with the internal compare voltage, judges the comparison result via software, and converts the analog signal into a 6-bit digital signal. the comparison result can be detected by the adccmp flag. as the comparison method, successive approximation is employed. figure 13-1. outline of a/d converter adcch1 flag adcch0 flag dbf adccmp flag p1b 0 /adc 0 p1b 1 /adc 1 set/reset 6 input select block compare voltage generator block (r-string d/a converter) compare block remarks 1. adcch0 and adcch1 (bits 0 and 1 of the a/d converter channel select register; refer to figure 13-3 ) select the pin used for the a/d converter. 2. adccmp (bit 0 of the a/d converter compare judge register; refer to figure 13-5 ) detects the result of comparison.
pd17012, 17p012 145 data sheet u10101ej4v0ds 13.2 input selector block figure 13-2 shows the configuration of the input selector block. the input selector block selects the pin to be used via the a/d converter channel select register. two or more pins cannot be used at the same time with the a/d converter. figure 13-3 shows the configuration and function of the a/d converter channel select register. figure 13-2. configuration of input selector block adcch1 flag adcch0 flag selector each i/o port compare block v adcin p1b 0 /adc 0 p1b 1 /adc 1 figure 13-3. configuration of a/d converter channel select register name flag symbol b 3 b 2 00 b 1 b 0 address 14h read/ write 0 0 1 1 0 1 0 1 sets pin used for a/d converter p1b 0 /adc 0 pin p1b 1 /adc 1 pin a/d converter is not used (general-purpose input port) a/d converter is not used (general-purpose input port) power-on clock stop ce 001 1 1 1 1 1 a/d converter channel select register fixed to 0 a d c c h 1 a d c c h 0 after reset r/w
pd17012, 17p012 146 data sheet u10101ej4v0ds 13.3 compare voltage generator block and compare block figure 13-4 shows the configuration of the compare voltage generator block and compare block. the compare voltage generator block switches over the tap decoder by using 6-bit data set to the a/d converter data register to generate 64 steps of compare voltage v ref . in other words, this block is an r-string d/a converter. the power source of the r string is the same as the v dd supplied to the device. the voltage applied to the resistor of the r string is only supplied when the adccmp flag is read by using the peek instruction. the compare block judges which of the voltage v adcin input from a pin and compare voltage v ref is greater. comparison is made by a comparator when the adccmp flag is read. therefore, one compare time of the a/d converter is equal to one instruction execution time (4.44 s). figures 13-5 and 13-6 show the configuration and function of the a/d converter compare judge register and a/ d converter data register. table 13-1 lists the compare voltages. figure 13-4. configuration of compare voltage generator block and compare block 1/2 v dd v dd dbf tap decoder 2 pf ? + comparator adccmp flag reading adccmp flag by peek instruction v adcin v ref a/d converter data register (adcr) 0126263 1 2 r 3 2 r rr
pd17012, 17p012 147 data sheet u10101ej4v0ds figure 13-5. configuration of a/d converter compare judge register remark u: undefined r: retained name flag symbol b 3 b 2 b 1 b 0 address 06h read/ write 0 1 detects result of comparison by a/d converter v adcin < v ref v adcin > v ref power-on clock stop ce 000u r r a/d converter compare judge register fixed to 0 000a d c c m p after reset r
pd17012, 17p012 148 data sheet u10101ej4v0ds figure 13-6. configuration of a/d converter data register data buffer dbf3 don't care dbf2 don't care dbf1 dbf0 transfer data 8 get put b 7 0 b 6 0 b 5 b 4 b 3 b 2 b 1 b 0 name peripheral register symbol adcr valid data 02h sets compare voltage of a/d converter 0 1 | x | ffh v ref v ref = 0 v fixed to 0 x ? 0.5 64 = v dd (v) a/d converter data register peripheral address
pd17012, 17p012 149 data sheet u10101ej4v0ds table 13-1. set values of a/d converter data register and compare voltages set data of adcr compare voltage set data of adcr compare voltage decimal hexadecimal logic voltage at v dd = 5 v decimal hexadecimal logic voltage at v dd = 5 v (dec) (hex) unit: v dd v unit: v (dec) (hex) unit: v dd v unit: v 0 00h 0 0 32 20h 31.5/64 2.461 1 01h 0.5/64 0.039 33 21h 32.5/64 2.539 2 02h 1.5/64 0.117 34 22h 33.5/64 2.617 3 03h 2.5/64 0.195 35 23h 34.5/64 2.695 4 04h 3.5/64 0.273 36 24h 35.5/64 2.773 5 05h 4.5/64 0.352 37 25h 36.5/64 2.852 6 06h 5.5/64 0.430 38 26h 37.5/64 2.930 7 07h 6.5/64 0.508 39 27h 38.5/64 3.008 8 08h 7.5/64 0.586 40 28h 39.5/64 3.086 9 09h 8.5/64 0.664 41 29h 40.5/64 3.164 10 0ah 9.5/64 0.742 42 2ah 41.5/64 3.242 11 0bh 10.5/64 0.820 43 2bh 42.5/64 3.320 12 0ch 11.5/64 0.898 44 2ch 43.5/64 3.398 13 0dh 12.5/64 0.977 45 2dh 44.5/64 3.477 14 0eh 13.5/64 1.055 46 2eh 45.5/64 3.555 15 0fh 14.5/64 1.133 47 2fh 46.5/64 3.633 16 10h 15.5/64 1.211 48 30h 47.5/64 3.711 17 11h 16.5/64 1.289 49 31h 48.5/64 3.789 18 12h 17.5/64 1.367 50 32h 49.5/64 3.867 19 13h 18.5/64 1.445 51 33h 50.5/64 3.945 20 14h 19.5/64 1.523 52 34h 51.5/64 4.023 21 15h 20.5/64 1.602 53 35h 52.5/64 4.102 22 16h 21.5/64 1.680 54 36h 53.5/64 4.180 23 17h 22.5/64 1.758 55 37h 54.5/64 4.258 24 18h 23.5/64 1.836 56 38h 55.5/64 4.336 25 19h 24.5/64 1.914 57 39h 56.5/64 4.414 26 1ah 25.5/64 1.992 58 3ah 57.5/64 4.492 27 1bh 26.5/64 2.070 59 3bh 58.5/64 4.570 28 1ch 27.5/64 2.148 60 3ch 59.5/64 4.648 29 1dh 28.5/64 2.227 61 3dh 60.5/64 4.727 30 1eh 29.5/64 2.305 62 3eh 61.5/64 4.805 31 1fh 30.5/64 2.383 63 3fh 62.5/64 4.883
pd17012, 17p012 150 data sheet u10101ej4v0ds 13.4 comparison timing chart the adcen flag is automatically cleared to 0 when the comparison operation has been completed. therefore, because the adcen flag is detected after it has been set, and the comparison result (adccmp flag) is read when the adcen flag has been cleared, one compare time is equal to three instruction execution times (6 s). figure 13-7 shows the timing chart. figure 13-7. timing chart of a/d converter? compare operation comparison result instruction cycle sample & hold adcen flag adccmp flag 13.5 performance of a/d converter the performance of the a/d converter is as follows. parameter performance resolution 6 bits input voltage range 0-v dd quantization error over range offset, gain, and non linearity errors note including quantization error. 1 2 lsb 62.5 64 v dd lsb note 3 2
pd17012, 17p012 151 data sheet u10101ej4v0ds 13.6 using a/d converter 13.6.1 comparing one compare voltage here is a program example. example to compare input voltage v adcin of the adc 0 pin with compare voltage v ref (31.5/64 v dd ) and branch to aaa if v adcin > v ref or to bbb if v adcin < v ref init: adcr7 flg 0.0eh.3 ; dummy adcr6 flg 0.0eh.2 ; dummy adcr5 flg 0.0eh.1 ; defines each bit of data buffer as adcr data setting adcr4 flg 0.0eh.0 ; flag adcr3 flg 0.0fh.3 adcr2 flg 0.0fh.2 adcr1 flg 0.0fh.1 adcr0 flg 0.0fh.0 clr2 adcch1, adcch0 ; sets p1b 0 /adc 0 pin for the a/d converter start: initflg not adcr3, not adcr2, not adcr1, not adcr0 initflg not adcr7, not adcr6, adcr5, not adcr4 put adcr, dbf ; sets compare voltage v ref to 31.5/64 v dd skt1 adccmp ; detects adccmp flag, and br aaa ; branches to aaa if false (0) br bbb ; branches to bbb if true (1)
pd17012, 17p012 152 data sheet u10101ej4v0ds 13.6.2 successive approximation by binary search method the a/d converter can compare only one voltage at one time. to convert an input voltage into a digital signal, therefore, successive approximation must be executed by program. if the processing time of the successive approximation program differs depending on the input voltage, the relationship with the other processing programs may be undesirable. therefore, use of the binary search method as explained in (1) through (3) below is recommended. (1) concept of binary search the concept of binary search is explained below. first, the compare voltage is set to 1/2 v dd . if the result of comparison is true (a high level is input), a voltage of 1/4 v dd is added to the result; if the result of comparison is false (a low level is input), a voltage of 1/4 v dd is subtracted from the result and compared. subsequently, the compare voltage is sequentially compared with 1/8 v dd and 1/16 v dd to 1/64 v dd . if the result of comparison is false after comparison has been executed six times, 1/64 v dd is subtracted from the result and comparison is completed. compare voltage ( v dd ) h l h l 1/2 3/4 1/4 7/8 5/8 h l h l 11/16 9/16 h l 3/8 1/8 h l h l 1/16 0 h l 15/16 h l 63/64 61/64 h l 59/64 h l h l h l 13/16 31/32 29/32 27/32 25/32 57/64 55/64 53/64 51/64 49/64 1 1 l 63/64 62/64 l 61/64 60/64 l 59/64 58/64 l 57/64 56/64 l 55/64 54/64 l 53/64 52/64 l 51/64 50/64 l 49/64 48/64 subtracts 1/64 if false 7/16 5/16 3/16 15/16 13/16 first time second time third time fourth time fifth time sixth time
pd17012, 17p012 153 data sheet u10101ej4v0ds (2) flowchart of binary search method start initialization : sets pin to be used adcr 100000b : sets compare voltage to 1/2 v dd end adccmp = 1? y n resets b 5 of adcr : if result is ?? subtracts 1/2 v dd : detects result of comparison sets b 4 of adcr : adds 1/4 v dd to result to set compare voltage regardless of whether result is ??or ? y n : detects result of comparison resets b 4 of adcr : if result is ?? subtracts 1/4 v dd sets b 3 of adcr : adds 1/8 v dd to result to set compare voltage regardless of whether result is ??or ?? adccmp = 1? y n : detects result of comparison resets b 3 of adcr : subtracts 1/8 v dd if result is ? sets b 2 of adcr : adds 1/16 v dd to result to set compare voltage regardless of whether result is ??or ?? adccmp = 1? y n : detects result of comparison resets b 2 of adcr : subtracts 1/16 v dd if result is ?? sets b 1 of adcr : adds 1/32 v dd to result to set compare voltage regardless of whether result is ??or ?? adccmp = 1? y n : detects result of comparison resets b 1 of adcr : subtracts 1/32 v dd if result is ?? sets b 0 of adcr : adds 1/64 v dd to result to set compare voltage regardless of whether result is ??or ?? adccmp = 1? y n : detects result of comparison resets b 0 of adcr : subtracts 1/64 v dd if result is ?? detects contents of adcr : completes conversion with current value if result is ?? adccmp = 1?
pd17012, 17p012 154 data sheet u10101ej4v0ds (3) program example of binary search method (a) method with short conversion time init: adcr7 flg 0.0eh.3 ; dummy adcr6 flg 0.0eh.2 ; dummy adcr5 flg 0.0eh.1 ; defines each bit of data buffer as adcr data setting flag adcr4 flg 0.0eh.0 adcr3 flg 0.0fh.3 adcr2 flg 0.0fh.2 adcr1 flg 0.0fh.1 adcr0 flg 0.0fh.0 clr2 adcch1, adcch0 ; sets p1b 0 /adc 0 pin for the a/d converter start: initflg not adcr3, not adcr2, not adcr1, not adcr0 initflg not adcr7, not adcr6, adcr5, not adcr4 put adcr, dbf ; sets compare voltage to 31.5/64 v dd skt1 adccmp ; detects adccmp and subtracts clr1 adcr5 ; 32/64 v dd if ??and adds set1 adcr4 ; 16/64 v dd put adcr, dbf skt1 adccmp ; detects adccmp and subtracts clr1 adcr4 ; 16/64 v dd if ??and adds set1 adcr3 ; 8/64 v dd put adcr, dbf skt1 adccmp ; detects adccmp and subtracts clr1 adcr3 ; 8/64 v dd if ??and adds a/d conversion set1 adcr2 ; 4/64 v dd put adcr, dbf skt1 adccmp ; detects adccmp and subtracts clr1 adcr2 ; 4/64 v dd if ??and adds set1 adcr1 ; 2/64 v dd put adcr, dbf skt1 adccmp ; detects adccmp and subtracts clr1 adcr1 ; 2/64 v dd if ??and adds set1 adcr0 ; 1/64 v dd put adcr, dbf skt1 adccmp ; detects adccmp and subtracts clr1 adcr0 ; 1/64 v dd if ? end: number of program steps: 31 steps number of execution steps: 31 steps a/d conversion time: 137.8 s
pd17012, 17p012 155 data sheet u10101ej4v0ds (b) method with fewer program steps adwork1 mem 0.00h ; work area for changing compare voltage adwork0 mem 0.01h initflg not adcch1, not adcch0 ; sets p1b 0 /adc 0 pin for the a/d converter start: mov dbf1, #0010b ; sets compare voltage to initial value of 31.5/64 v dd mov dbf0, #0000b mov adwork1, #0001b mov adwork0, #0000b ad_check: put adcr, dbf ; sets compare voltage v ref skt1 adccmp ; detects adccmp flag br adin_l add dbf0, adwork0 ; increases compare voltage if ? addc dbf1, adwork1 br next_ad a/d adin_l: conversion sub dbf0, adwork0 ; decreases compare voltage if ? subc dbf1, adwork1 ;nop ; described to keep a/d conversion time constant next_ad: rorc adwork1 rorc adwork0 skt1 cy ; 6 bits completed? br ad_check put adcr, dbf skt1 adccmp and dbf0, #1110b . . . number of program steps: 22 steps number of execution steps: 58 to 63 steps a/d conversion time: 257.8 to 280 s where the a/d conversion time is held constant number of program steps: 23 steps number of execution steps: 63 steps a/d conversion time: 280 s
pd17012, 17p012 156 data sheet u10101ej4v0ds 13.7 status on reset 13.7.1 on power-on reset all the p1b 1 /adc 1 and p1b 0 /adc 0 pins are set in the general-purpose input port mode. 13.7.2 on execution of clock stop instruction all the p1b 1 /adc 1 and p1b 0 /adc 0 pins are set in the general-purpose input port mode. 13.7.3 on ce reset all the p1b 1 /adc 1 and p1b 0 /adc 0 pins are set in the general-purpose input port mode.
pd17012, 17p012 157 data sheet u10101ej4v0ds 14. d/a converter (dac) the d/a converter (dac) outputs its signal by means of pwm (pulse width modulation), which varies the duty factor. by connecting an external lowpass filter to the d/a converter, digital signals can be converted into analog signals. 14.1 configuration of d/a converter figure 14-1 shows the block diagram of the d/a converter. as shown in the figure, the d/a converter consists of an output select block and a duty setting block for each pin, and a clock generation block. figure 14-1. block diagram of d/a converter control register output select block p0c 1 /pwm 1 duty setting block data buffer f pwm1 clock generation block output select block p0c 0 /pwm 0 f pwm0 duty setting block 14.2 functional outline of d/a converter the d/a converter outputs a variable-duty signal to each output pin. the output frequency is 4.4 khz, and the duty factor can be changed in 256 steps. the following subsections 14.2.1 through 14.2.3 outline the function of each block of the d/a converter. 14.2.1 output select blocks the output select blocks specify whether each pin is used as a general-purpose output port pin or a d/a converter pin. the mode of each pin is selected by pwm1sel and pwm0sel of the pwm mode select register (refer to 14.3 ). 14.2.2 duty setting blocks the duty setting blocks output a signal whose duty factor can be changed in 256 steps. the duty factor of each output pin is independently set by the pwm data register (pwmr0 or pwmr1: peripheral address 04h or 05h) via the data buffer (refer to 14.4 ). 14.2.3 clock generation block the clock generation block generates a basic clock that is used to set the duty factor of the output signal. the generated clock frequency f pwm is 1.125 mhz (refer to 14.4 ).
pd17012, 17p012 158 data sheet u10101ej4v0ds 14.3 output select blocks 14.3.1 configuration of output select blocks figure 14-2 shows the configuration of the output select blocks. figure 14-2. configuration of output select blocks output latch p0c 1 /pwm 1 1 0 duty setting block pwm1sel flag pwm0sel flag p0c 0 /pwm 0 1 0 duty setting block output latch 14.3.2 function of output select blocks the output select blocks select whether the p1b 2 /pwm 1 and p1b 1 /pwm 0 pins are used as general-purpose output port pins or d/a converter pins. this selection can be made by the pwm1sel and pwm0sel flags of the pwm mode select register. each pin can be set in the port mode or d/a converter mode independently. the p0c 1 /pwm 1 and p0c 0 /pwm 0 pins are n-ch open-drain output pins and must be connected with an external pull-up resistor. the configuration and function of the pwm mode select register is shown in figure 14-3.
pd17012, 17p012 159 data sheet u10101ej4v0ds figure 14-3. configuration of pwm mode select register name flag symbol b 3 b 2 b 1 b 0 address 13h read/ write 0 1 sets function of p0c 0 /pwm 0 pin general-purpose output port d/a converter power-on clock stop ce 000 0 0 0 retained pwm mode select register sets function of p0c 1 /pwm 1 pin general-purpose output port d/a converter fixed to 0 0 1 00p w m 1 s e l p w m 0 s e l after reset r/w
pd17012, 17p012 160 data sheet u10101ej4v0ds 14.4 duty setting blocks and clock generation block 14.4.1 configuration of duty setting blocks and clock generation block figure 14-4 shows the configuration of the duty setting blocks and clock generation block. figure 14-4. configuration of duty setting blocks and clock generation block data buffer (dbf) address symbol data 0ch dbf3 don't care 0dh dbf2 don't care 0eh dbf1 0fh dbf0 m s b 8 peripheral address 05h pwm1 data register (pwmr1) comparator counter (8 bits) pwm0 data register (pwmr0) comparator counter (8 bits) 8 peripheral address 04h to output block to output block f pwm1 1.125 mhz f pwm0 1.125 mhz clock generation block l s b 14.4.2 function and configuration of clock generation blocks the clock generation block outputs the basic clocks (f pwm1 and f pwm0 ) that set the duty factor of each output signal (of pwm 1 and pwm 0 pins). the output frequency is 1.125 mhz (0.89 s) for both f pwm1 and f pwm0 . however, f pwm1 and f pwm0 have the following phase difference. f pwm1 f pwm0 222 ns 222 ns 888 ns
pd17012, 17p012 161 data sheet u10101ej4v0ds 14.4.3 function and operation of duty setting blocks the duty setting blocks compare the value set to each pwm data register (pwm1 and pwm0) with the value of each basic clock (f pwm1 and f pwm0 ) counted by an 8-bit counter, and output a high level if the value of the pwm data register is greater, and a low level if the value of pwm data register is less. where the value set to the pwm data register is ?? the duty factor is as follows. x + 0.25 duty factor: d = 100% 256 0.25 is an offset. a high level is output even when x = 0. because the basic clock is 1.125 mhz, the frequency and cycle of the output signal are as follows. 1.125 mhz frequency: f = = 4.3945 khz 256 256 cycle: t = = 227.6 s 1.125 mhz an independent value can be set to each pwm data register via the data buffer. in other words, each pin can output a signal with an independent duty factor. the following subsections 14.4.4 and 14.4.5 explain the configuration and function of each pwm data register, and the relationship between the output waveform and duty factor of each pin.
pd17012, 17p012 162 data sheet u10101ej4v0ds 14.4.4 configuration and function of each pwm data register the function of each pwm data register is illustrated below. the pwm data register sets the duty factor of a d/a converter (pwm output) output signal. name symbol address bit data data buffer dbf3 0ch don't care dbf2 0dh don't care dbf1 0eh dbf0 0fh b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 transfer data 8 get can be executed put can be executed b 7 b 6 b 5 b 4 b 3 b 2 b 1 b 0 name peripheral register symbol pwmr0 pwmr1 valid data peripheral address 04h 05h peripheral hardware sets pwm output duty of each pin 0 x 255 x + 0.25 256 pwm 0 pin pwm 1 pin duty: d = 100% = 4.3945 khz 1.125 mhz 256 pwm0 data register pwm1 data register frequency: f =
pd17012, 17p012 163 data sheet u10101ej4v0ds 14.4.5 relationship of output waveform and each pin of d/a converter (1) shows the relationship between the output waveform and duty factor. (2) shows the relationship of the output waveform of each pin. (1) duty factor and output waveform x = 0 x = 1 x = 2 x = 255 888 ns 888 ns 222 ns 666 ns 227.6 s (2) output waveform of each pin pwm 1 (x = 0) pwm 0 (x = 0) 222 ns 227.6 s 14.5 cautions on using d/a converter (1) the initial pwm output setting following the power on application is made in the following procedure. this is because the pwm data register is undefined so that data should be set beforehand. <1> set the value of pwm data register <2> set the pwmnsel flag (2) do not overwrite the data of pwm data register during pwm operation. the output of the correct duty for one cycle (227.6 s) cannot be obtained.
pd17012, 17p012 164 data sheet u10101ej4v0ds 14.6 status on reset 14.6.1 on power-on reset the p0c 1 /pwm 1 and p0c 0 /pwm 0 pins are set in the general-purpose output port mode. the output value is undefined. the value of each pwm data register is undefined. 14.6.2 on execution of clock stop instruction the p0c 1 /pwm 1 and p0c 0 /pwm 0 pins are set in the general-purpose output port mode. the output value is the previous contents of the output latch. each pwm data register retains the previous value. 14.6.3 on ce reset the p0c 1 /pwm 1 and p0c 0 /pwm 0 pins retain the previous output status. therefore, the pin used for the d/a converter retains the current pwm output. 14.6.4 in halt status the p0c 1 /pwm 1 and p0c 0 /pwm 0 pins retain the previous output status. therefore, the pin used for the d/a converter retains the current pwm output.
pd17012, 17p012 165 data sheet u10101ej4v0ds 15. serial interface the serial interface is used to transfer 8-bit serial data with an external device. figure 15-1. block diagram of serial interface control register data buffer clock control i/o con- trol clock generation presettable shift register serial interface p0a 2 /sck 1 p0a 1 /so 1 p0a 0 /si 1 peripheral address 03h
pd17012, 17p012 166 data sheet u10101ej4v0ds 15.1 configuration of serial interface figure 15-2 shows the configuration of the serial interface. as shown in the figure, the shift clock control block of the serial interface consists of a clock i/o pin control block, clock generation block, wait control block, and clock count block. the serial data control block consists of a serial data i/o pin control block and a presettable shift register. these blocks are controlled by the corresponding flags of the control registers. data is written to or read from the presettable shift register via the data buffer. the following section 15.2 outlines each block. figure 15-2. configuration of serial interface address flag symbol control register 02h data buffer (dbf) address symbol data 0ch dbf3 0dh dbf2 0eh dbf1 0fh dbf0 03h p0a 2 /sck 1 output control output latch write port register read p0abio2 flag p0a 2 /sck 1 shift clock i/o pin control block p0a 1 /so 1 output control output latch write port register read p0abio1 flag p0a 1 /so 1 serial data i/o pin control block output latch write port register read p0abio0 flag p0a 0 /si 1 sf8 sf8 wait serial clock input clkout clock control wait control clock counter shift clock output serial out data dataout clkin datain presettable shift register serial in data m s b l s b s i o 1 t s s i o 1 h i z s i o 1 c k 1 s i o 1 c k 0
pd17012, 17p012 167 data sheet u10101ej4v0ds 15.2 functional outline of serial interface the serial interface uses the p0a 2 /sck 1 , p0a 1 /so 1 , and p0a 0 /si 1 pins. the serial interface can select the internal clock or an external clock, and can execute receive and transmit the following subsections 15.2.1 to 15.2.6 outline the functions of the respective blocks of the serial interface. for details of each block, refer to 15.3 to 15.7 . 15.2.1 shift clock i/o pin control block this block selects the shift clock i/o pin. the shift clock i/o pin is selected by the serial i/o mode select register. refer to 15.3 . 15.2.2 serial data i/o pin control block this block selects the serial data i/o pin. the serial data i/o pin is selected by the serial i/o mode select register. refer to 15.3 . 15.2.3 clock generation block this block selects the clock frequency of the shift clock and controls the shift clock output timing. the shift clock frequency is selected by the serial i/o mode select register. refer to 15.4 . 15.2.4 clock counter the clock counter counts the number of rising edges of the clock output by the shift clock output pin and outputs a signal at the eighth clock (sf8 signal). the sf8 signal is used to make serial communication wait (pause). refer to 15.5 . 15.2.5 presettable shift register (sio1sfr) this shift register sets serial out data and stores serial in data. it performs a shift operation by using the clock of the shift clock i/o pin and inputs/outputs data. the output data is set and the input data is read via the data buffer. refer to 15.6 . 15.2.6 wait control block this block places or releases serial communication in or from the wait status. serial communication is placed in or released from the wait status by the serial i/o mode select register. refer to 15.7 .
pd17012, 17p012 168 data sheet u10101ej4v0ds 15.3 shift clock and serial data i/o pin control blocks the shift clock and serial data i/o pin control blocks set the pins of the serial interface and control the transmit/receive operations. these control operations are specified by the serial i/o mode select register. 15.3.1 shows the configuration and function of the serial i/o mode select register. 15.3.2 indicates the status of each pin set by the serial i/o mode select register. 15.3.1 configuration and function of serial i/o mode select register the configuration and function of the serial i/o mode select register are illustrated below. the sio1ck1 and sio1ck0 flags are used to select the internal clock or an external clock and to set the frequency of the internal clock. for details of the clock, refer to 15.4 . the sio1ts flag places or releases the serial interface in or from the wait status. for the wait operation, refer to 15.7 . name flag symbol b 3 b 2 b 1 b 0 address 02h read/ write 0 1 0 1 sets i/o clock frequency of serial interface external clock (slave) 37.5 khz (master) 75 khz (master) 450 khz (master) after reset power-on clock stop ce 0 0 0 0 0 0 0 0 0 0 0 0 serial i/o mode select register sets p0a 1 /so 1 pin as serial out pin general-purpose i/o port serial out starts serial communication of serial interface does not start serial communication (wait) starts serial communication (wait release) 0 1 0 1 0 0 1 1 s i o 1 t s s i o 1 h i z s i o 1 c k 1 s i o 1 c k 0 r/w
pd17012, 17p012 169 data sheet u10101ej4v0ds 15.3.2 pin status setting by serial i/o mode select register table 15-1 shows the status of each pin set by the serial i/o mode select register. as shown in this table, the i/o select flag of each pin must also be manipulated to set each pin. for details of the i/o select flag, refer to 10. general-purpose ports . table 15-1. pin status setting by serial i/o mode select register communication mode sio1mode b 2 b 1 b 0 pin 3-wire serial i/o s i o 1 c k 0 s i o 1 c k 1 setting of serial output clock direction pin symbol s i o 1 h i z p 0 a b i o 1 p 0 a b i o 2 p 0 a b i o 0 wait : general-purpose input port wait released : external clock input external clock general- purpose port serial output internal clock 00 01 10 11 0 1 p0a 1 /so 1 p0a 0 /si 1 p0a 2 /sck 1 0 1 0 1 0 1 0 1 0 1 wait : general-purpose output port wait released : external clock input wait : general-purpose input port wait released : internal clock output wait : general-purpose output port wait released : general-purpose input port general-purpose input port general-purpose output port general-purpose input port serial output serial input general-purpose output port i/o select flag of each pin pin setting status
pd17012, 17p012 170 data sheet u10101ej4v0ds 15.4 clock generation block the clock generation block generates the clock when the internal clock is used (i.e., when a master operation is performed) and controls the clock output timing. the frequency f sc of the internal clock is set by using the sio1ck1 and sio1ck0 flags of the serial i/o mode select register. the shift clock is successively output until the value of the clock counter, which is explained in 15.5, reaches ?? the following subsection 15.4.1 explains the clock output waveform and clock generation timing. 15.4.1 internal shift clock generation timing (1) on releasing wait status from initial status the initial status is the status in which the internal clock is selected and the p0a 2 /sck 1 pin is set in the output mode. a high level is output to the p0a 2 /sck 1 pin in the wait status. wait release and clock selection can be made simultaneously. initialization wait release wait status shift clock 1/f sc 1 : 1
pd17012, 17p012 171 data sheet u10101ej4v0ds (2) when wait operation is performed for details of the wait operation, refer to 15.7 . (a) wait status with value of clock counter reaching ??(normal operation) shift clock pin h l wait status wait wait release 1/f sc wait released status contents of output latch (b) if forced wait is executed in wait status shift clock pin h l wait period wait period forced wait by sio1ts contents of output latch contents of output latch (c) if forced wait is executed when wait status is released at this time, the clock counter is reset. (d) if wait status is released in wait release status the clock output waveform is not changed at this time. the clock counter is not reset. however, do not change the clock frequency during wait release. shift clock pin h l h l wait release status wait status 1/f sc forced wait by sio1ts wait release 1/f sc shift clock pin wait release status wait status forced wait by sio1ts wait release contents of output latch contents of output latch
pd17012, 17p012 172 data sheet u10101ej4v0ds 15.5 clock counter the clock counter is a wrap-around counter that counts the number of the shift clocks output from or input to the shift clock (p0a 2 /sck 1 ) pin. the clock counter directly reads the status of the shift clock pin. at this time, whether the clock is the internal clock or an external clock is not identified. the clock counter does not operate in the wait status of serial communication. when the value of the clock counter is 8, serial communication is placed in the wait status at the rising edge of the shift clock. the contents of the clock counter cannot be directly read by program. the following subsections 15.5.1 and 15.5.2 explain the operation of the clock counter and the conditions under which the clock counter is reset. 15.5.1 operation of clock counter figure 15-3 shows the operation of the clock counter. the initial value of the clock counter is 0. the value of the clock counter is incremented by one each time the falling of the shift clock pin is detected. when the value of the clock counter has been incremented to 8, the clock counter is reset to 0 at the next rising edge of the shift clock pin. serial communication is placed in the wait status when the clock counter has been reset to 0. figure 15-3. operation of clock counter shift clock pin h l serial data pin h l clock counter resets clock counter releases wait 012 3 780 123 78 d7 d6 d1 d5 d0 wait 15.5.2 clock counter reset condition the clock counter is reset to 0 when any of the following conditions (1) through (5) is satisfied. (1) on power-on reset (2) on execution of the clock stop instruction (3) when 0 is written to the sio1ts flag (forced wait) (4) when the shift clock rises while the value of the clock counter is 8 with the wait status released (5) on ce reset
pd17012, 17p012 173 data sheet u10101ej4v0ds 15.6 presettable shift register (sio1sfr) the presettable shift register is an 8-bit shift register that writes serial out data and reads serial in data. data is written to or read from the presettable shift register via the data buffer by using the put or get instruction. 15.6.1 shows the configuration of the presettable shift register and its relationship with the data buffer. the presettable shift register performs its shift operation in synchronization with the clock applied to the shift clock (p0a 2 /sck 1 ) pin. at this time, the contents of the most significant bit (msb) of the presettable shift register are output to the serial data output pin in synchronization with the fall of the shift clock, and the least significant bit (lsb) of the presettable shift register is read in synchronization with the rise of the clock. 15.6.2 explains the points to be noted when writing or reading data to or from the presettable shift register. the presettable shift register does not shift data in the wait status. for details of the operation in each serial communication mode, refer to 15.8 . 15.6.1 configuration of presettable shift register and its relationship with data buffer the configuration of the presettable shift register and its relationship with the data buffer are shown below. name symbol address bit data data buffer dbf3 0ch don't care dbf2 0dh don't care dbf1 0eh dbf0 0fh b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 transfer data 8 get can be executed note put can be executed note b 7 b 6 b 5 b 4 b 3 b 2 b 1 b 0 name peripheral register symbol sio1sfr valid data peripheral address 03h peripheral hardware sets serial out data and reads serial in data d7 d6 d5 d4 d3 d2 d1 d0 serial out presettable shift register d7 d6 d5 d4 d3 d2 d1 d0 l s b m s b serial interface serial in note if put or get is executed in serial communication mode, data may be corrupted. for details, refer to 15.6.2 notes on setting and reading data .
pd17012, 17p012 174 data sheet u10101ej4v0ds 15.6.2 notes on setting and reading data data is written to the presettable shift register by the put sio1sfr, dbf instruction. data is read from the register by the get dbf, sio1sfr instruction. set or read data to or from the register in the wait status. while the wait status is released, the data may not be correctly set or read depending on the status of the shift clock pin. table 15-2 indicates the timing of setting and reading data and points to be noted. table 15-2. reading (get) and writing (put) data from/to presettable shift register and notes status on execution status of shift clock pin operation of presettable shift register (sio1sfr) of put/get wait read (get) with external clock: normally read. status floated write (put) normally written. with internal clock: content of msb is output at falling edge of shift clock when wait normally the output status is released next time (during transfer operation). latch value is used at high level. wait read (get) low level normally read. released high level cannot be read normally. status contents of sio1sfr are destroyed. write (put) low level normally written. contents of msb are output when put instruction is executed. clock counter is not reset. high level cannot be written normally. contents of sio1sfr are destroyed. clock data msb put sio1sfr, dbf clock data put sio1sfr, dbf wait released msb
pd17012, 17p012 175 data sheet u10101ej4v0ds 15.7 wait control block the wait control block controls communication of the serial interface by placing or releasing communication in or from the wait status. the wait control block is controlled by the sio1ts flag of the serial i/o mode select register. the following subsection 15.7.1 explains the wait operation and points to be noted. 15.7.1 wait operation and notes in the wait status, the clock generation block and presettable shift register stop operation, and serial communication pauses. therefore, serial communication can be started when the wait status is released. the wait status is released when 1 is written to the sio1ts flag. when 1 is written to this flag, the internal clock is output to the shift clock output pin (during master operation), and presettable shift register and clock counter start operating. if the shift clock rises when the value of the clock counter is 8, the wait status is set. at this time, the sio1ts flag is automatically reset to 0. the operating status of serial communication can be checked by detecting the content of the sio1ts flag while the wait status is released. therefore, data is read or set after 1 has been written to the sio1ts flag, serial communication has been started, and then clearing of the sio1ts flag to 0 has been detected. if data is written to (by put instruction) or read from (by get instruction) the presettable shift register while the wait status is released, the correct data may not be written or read. for details, refer to 15.6.2 notes on setting and reading data . if 0 is written to the sio1ts flag while the wait status is released, the wait status is set. this is called forced wait. when forced wait is executed, the clock counter is reset to 0. figure 15-4 shows an example of the wait operation.
pd17012, 17p012 176 data sheet u10101ej4v0ds figure 15-4. example of wait operation h l serial data input pin h l shift clock pin sio1ts 1 0 h l serial data output pin clock counter wait status wait released wait released status wait status wait 0780 3 12 previous value d7 d7 d6 d6 d1 d1 d0 d0 d5 d5 123 78 when the wait is released, the serial data is output at the next falling edge of the clock, and the status becomes the wait released status. when the shift clock has been input eight times, the shift clock pin outputs a high level, and the clock counter and presettable shift register stop operation. if data is written to or read from the presettable shift register while the wait status is released and the shift clock pin is high, the correct data may not be set or read. if data is written to the presettable shift register while the wait status is released and the shift clock pin is low, the contents of the msb are output to the serial data output pin as soon as the put instruction has been executed. if a forced wait is executed while the wait status is released, the wait status is set and the clock counter is reset to 0 as soon as 0 has been written to the sio1ts flag.
pd17012, 17p012 177 data sheet u10101ej4v0ds 15.8 outline of serial interface operation table 15-3 shows an outline of the serial interface operation in each mode. table 15-3. outline of serial interface operation in each mode operation 3-wire serial i/o mode mode slave operation master operation item sio1ck1 = sio1ck0 = 0 sio1ck1 = sio1ck0 = other than 0 p0a 2 /sck 1 wait wait released wait wait released setting status of each pin p0a 1 /so 1 p0a 0 /si 1 when p0abio0 = 0 floating waits for external data when p0abio0 = 1 general-purpose output port. outputs contents of output latch operation of clock incremented at falling edge of sck 1 pin counter operation of output presettable shift when sio1hiz = 1 register (sio1sfr) shifts data from msb and outputs it to so 1 pin at falling edge of sck 1 pin when sio1hiz = 0 does not output data input shifts data of si 1 pin from lsb and inputs it at rising edge of sck 1 pin regardless of p0abio0 however, the contents of output latch are output to si 1 pin when p0abio0 = 1 wait operation serial communication is started when 1 is written to sio1ts. sio1ts is reset to 0 at rising edge of shift clock when value of clock counter is 8. for the operation of each pin, refer to above. when p0abio2 = 0 floating general-purpose input port when p0abio2 = 1 general-purpose output port outputs contents of output latch when sio1hiz = 0 when p0abio1 = 0 general-purpose input port floating when p0abio1 = 1 general-purpose output port outputs contents of output latch regardless of p0abio2 floating wait external clock input when sio1hiz = 1 when p0abio1 = 0 general-purpose input port floating when p0abio1 = 1 outputs serial data when p0abio2 = 0 floating general-purpose input port when p0abio2 = 1 general-purpose output port outputs contents of output latch when sio1hiz = 0 when p0abio1 = 0 general-purpose input port floating when p0abio1 = 1 general-purpose output port outputs contents of output latch regardless of p0abio2 outputs internal clock when sio1hiz = 1 when p0abio1 = 0 general-purpose input port floating when p0abio1 = 1 outputs serial data
pd17012, 17p012 178 data sheet u10101ej4v0ds 15.9 status of serial interface on reset 15.9.1 on power-on reset each pin is set in the general-purpose input port mode (floating output). the value of the presettable shift register is undefined. 15.9.2 on execution of clock stop instruction each pin is set in the general-purpose input port mode (floating output). the presettable shift register retains the previous value. 15.9.3 on ce reset each pin is set in the general-purpose input port mode (floating output). the presettable shift register retains the previous value. 15.9.4 in halt status each pin retains the current status. if the internal clock is used (master operation) at this time, the clock is not output after the halt instruction has been executed. to use the internal clock, therefore, the halt instruction must be executed after communication has been completed. if an external clock is forcibly input, the serial interface functions even when the internal clock is used. if the external clock is used (slave operation), the operation continues even when the halt instruction has been executed.
pd17012, 17p012 179 data sheet u10101ej4v0ds 16. pll frequency synthesizer the pll (phase locked loop) frequency synthesizer is used to lock the frequency in the mf (medium frequency), hf (high frequency), and vhf (very high frequency) bands to a specific frequency by comparing phase differences. 16.1 configuration of pll frequency synthesizer figure 16-1 shows the block diagram of the pll frequency synthesizer. as shown in the figure, the pll frequency synthesizer consists of an input select block, programmable divider (pd), phase comparator ( -det), reference frequency generator (rfg), and charge pump. by connecting these blocks with an external lowpass filter (lpf) and voltage-controlled oscillator (vco), a pll frequency synthesizer is organized. figure 16-1. block diagram of pll frequency synthesizer control register input select block programmable divider (pd) phase comparator ( -det) charge pump unlock detection block voltage-controlled oscillator (vco) lowpass filter (lpf) reference frequency generator (rfg) note note eo vcoh vcol data buffer note external circuit
pd17012, 17p012 180 data sheet u10101ej4v0ds 16.2 functional outline of pll frequency synthesizer the pll frequency synthesizer divides a signal input from the vcoh or vcol pin by using the programmable divider and outputs a phase difference from the reference frequency from the eo pin. the pll frequency synthesizer operates only when the ce pin is high, and is disabled when the ce pin is low. for details of the disabled status of the pll frequency synthesizer, refer to 16.6 . the following subsections 16.2.1 through 16.2.6 outline the function of each block of the pll frequency synthesizer. 16.2.1 input select block this block selects the pin from which a signal output from an external voltage-controlled oscillator is input. as the input pin, the vcoh or vcol pin is selected by the pll mode select register (rf address 21h). for details, refer to 16.3 . 16.2.2 programmable divider the programmable divider divides the signal input from the vcoh or vcol pin at the division ratio set by the program. two types of division modes can be selected: direct division and pulse swallow modes. the division mode is selected by the pll mode select register. the division ratio is set by the pll data register (pllr: peripheral address 41h) via the data buffer. for details, refer to 16.3 . 16.2.3 reference frequency generator this generator generates a reference frequency to be compared by the phase comparator. twelve types of reference frequencies can be selected by using the pll reference clock select register (rf address 31h). for details, refer to 16.4 . 16.2.4 phase comparator and unlock detection block the phase comparator compares the division signal output by the programmable divider with the signal from the reference frequency generator, and outputs a phase difference. the unlock detection block detects the unlock status of the pll. the unlock status of the pll is detected by the pll unlock ff judge register (rf address 05h). for details, refer to 16.5 . 16.2.5 charge pump the charge pump outputs the signal output by the phase comparator to the eo pin as a high-level, low-level, or floating signal. for details, refer to 16.5 .
pd17012, 17p012 181 data sheet u10101ej4v0ds 16.3 input select block and programmable divider 16.3.1 configuration of input select block and programmable divider figure 16-2 shows the configuration of the input select block and programmable divider. as shown in the figure, the input select block consists of the vcoh and vcol pins, and the amplifiers of the respective pins. the programmable divider consists of a 2-modulus prescaler, swallow counter, programmable counter, and division mode select switch. figure 16-2. configuration of input select block and programmable divider address bit control register 21h b 3 b 2 b 1 b 0 data buffer (dbf) 0ch dbf3 m s b 0dh dbf2 0eh dbf1 0fh dbf0 l s b address symbol data 16 pll data register 12 bits 4 bits 12 4 swallow counter 4 bits programmable counter 12 bits f n to -det mf vhf hf 2-modulus prescaler 1/16, 1/17 hf mf vhf pll disable signal mf hf vhf vcoh vcol 2-4 decoder psc peripheral address 41h 00p l l m d 1 p l l m d 0 flag symbol
pd17012, 17p012 182 data sheet u10101ej4v0ds 16.3.2 functions of input select block and programmable divider the input select block and programmable divider select the input pin and division mode of the pll frequency synthesizer. as the input pin, the vcoh or vcol pin can be selected. the selected pin goes into an intermediate-potential state (approx. 1/2 v dd ). the pin not selected is internally pulled down. these pins input signals via an ac amplifier, and the dc component of the input signal must be cut off by connecting a capacitor to the pin in series. either the direct division mode or pulse swallow mode can be selected as the division mode. the programmable counter divides the signal input from the vcoh or vcol pin in a specified division mode according to the values set to the swallow counter and programmable counter. table 16-1 show the input pins (vcoh and vcol) and division modes. the input pin and division mode to be used are selected by the pll mode select register. 16.3.3 explains the configuration and function of the pll mode select register. the division ratio is set to the programmable divider by the pll data register via the data buffer. 16.3.4 explains the programmable divider and pll data register. table 16-1. input pins and division modes division mode pin input frequency input amplitude settable division division ratio settable in (mhz) (v p-p ) ratio data buffer direct division vcol 0.5 to 20 0.3 16 to 2 12 ?1 010 h to fff h (mf) ( : lower 4 bits are arbitrary) pulse swallow vcol 5 to 30 0.3 256 to 2 16 ?1 0100h to ffffh (hf) pulse swallow vcoh 50 to 150 0.3 256 to 2 16 ?1 0100h to ffffh (vhf) 30 to 250 ----------------------------
pd17012, 17p012 183 data sheet u10101ej4v0ds 16.3.3 configuration and function of pll mode select register the pll mode select register specifies the division mode of the pll frequency synthesizer and the pin to be used. the configuration and function of the pll mode select register are shown below. the paragraphs (1) through (4) below outline the respective division modes. (1) direct division mode (mf) in this mode, the vcol pin is used. the vcoh pin is pulled down. in the direct division mode, the frequency of the input signal is divided only by the programmable counter. (2) pulse swallow mode (hf) the vol pin is used in this mode. the vcoh pin is pulled down. in this mode, the frequency of the input signal is divided by the swallow counter and programmable counter. (3) pulse swallow mode (vhf) the vcoh pin is used in this mode. the vcol pin is pulled down. in this mode, the frequency of the input signal is divided by the swallow counter and programmable counter. (4) disabling vcol and vcoh pins the vcoh and vcol pins are internally pulled down. however, the phase comparator, reference frequency generator, and charge pump operate. therefore, the operation is different from that in the pll disable status to be explained later. name flag symbol b 3 b 2 b 1 b 0 address 21h read/ write 0 0 1 1 0 1 0 1 sets division mode of pll frequency synthesizer disables vcol and vcoh pins direct division mode (vcol pin, mf mode) pulse swallow (vcoh pin, vhf mode) pulse swallow (vcol pin, hf mode) power-on clock stop ce 000 0 0 0 pll mode select register fixed to 0 retained 00p l l m d 1 p l l m d 0 after reset r/w
pd17012, 17p012 184 data sheet u10101ej4v0ds 16.3.4 programmable divider and pll data register the programmable divider divides the signal input from the vcoh or vcol pin by the value set to the swallow counter and programmable counter. the swallow counter and programmable counter are 4-bit binary down counters. the division ratio is set to the swallow counter and programmable counter by the pll data register (pllr: peripheral address 41h) via data buffer. data is set to or read from the pll data register by using the put pllr, dbf or get dbf, pllr instruction. the value to be divided is called n value. for how to set the n value in each division mode, refer to 16.7 . (1) pll data register and data buffer the relationship between the pll data register and data buffer is explained next. in the direct division mode, the higher 12 bits are valid, and all 16 bits are valid in the pulse swallow mode. in the direct division mode, all the higher 12 bits are set to the programmable counter. in the pulse swallow mode, the higher 12 bits are set to the programmable counter, and the lower 4 bits are set to the swallow counter. (2) relationship between division value n and divided output frequency the relationship between the value n set to the pll data register and the frequency f n of the signal divided and output by the programmable divider is as follows. for details, refer to 16.7 . (a) in direct division mode (mf) f in f n = n: 12 bits n (b) in pulse swallow mode (hf and vhf) f in f n = n: 16 bits n
pd17012, 17p012 185 data sheet u10101ej4v0ds name symbol address bit data data buffer dbf3 0ch dbf2 0dh dbf1 0eh dbf0 0fh b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 transfer data 16 get can be executed put can be executed b 15 b 14 b 13 b 12 b 11 b 10 b 9 b 8 b 7 b 6 b 5 b 4 b 3 b 2 b 1 b 0 name pll data register peripheral register symbol pllr valid data 41h peripheral address pll frequency synthesizer sets division value of pll frequency synthesizer 0 15 (00fh) 16 (010h) x 2 12 1 (fffh) 0 255 (00ffh) 256 (0100h) x 2 16 1 (ffffh) don't care don't care don't care don't care don't care direct division mode setting prohibited division value n: n = x setting prohibited division value n: n = x peripheral address pulse swallow mode
pd17012, 17p012 186 data sheet u10101ej4v0ds 16.4 reference frequency generator 16.4.1 configuration and function of reference frequency generator figure 16-3 shows the configuration of the reference frequency generator. as shown in the figure, the reference frequency generator divides the crystal oscillator s 4.5 mhz to generate the reference frequency f r of the pll frequency synthesizer. twelve reference frequencies can be selected: 1, 1.25, 2.5, 3, 5, 6.25, 9, 10, 12.5, 25, 50, and 100 khz. reference frequency f r is selected by the pll reference clock select register. 16.4.2 shows the configuration and function of the pll reference clock select register. figure 16-3. configuration of reference frequency generator (rfg) address bit flag symbol control register 31h b 3 b 2 b 1 b 0 4-16 decoder mux pll disable signal to -det divider 4.5 mhz 1 khz 1.25 khz 2.5 khz 50 khz 100 khz p l l r f c k 3 p l l r f c k 2 p l l r f c k 1 p l l r f c k 0
pd17012, 17p012 187 data sheet u10101ej4v0ds 16.4.2 configuration and function of pll reference clock select register the configuration and function of the pll reference clock select register are shown below. when the pll is disabled by the pll reference clock select register, the vcoh and vcol pins are internally pulled down. the eo pin is floated. for disabling the pll, refer to 16.6 . name flag symbol b 3 b 2 b 1 b 0 address 31h read/ write 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 sets reference frequency f r of pll frequency synthesizer 1.25 khz 2.5 khz 5 khz 10 khz 6.25 khz 12.5 khz 25 khz 50 khz 3 khz setting prohibited setting prohibited setting prohibited 1 khz 9 khz 100 khz pll disabled power-on clock stop ce 1 1 1 1 1 1 1 1 pll reference clock select register retained 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 p l l r f c k 3 p l l r f c k 2 p l l r f c k 1 p l l r f c k 0 after reset r/w
pd17012, 17p012 188 data sheet u10101ej4v0ds 16.5 phase comparator ( -det), charge pump, and unlock detection block 16.5.1 configuration of phase comparator, charge pump, and unlock detection block figure 16-4 shows the configuration of the phase comparator, charge pump, and unlock detection block. the phase comparator compares the divided frequency output f n of the programmable divider with the reference frequency output f r of the reference frequency generator, and outputs an up request (up) or down request (dw) signal. the charge pump outputs the output of the phase comparator from the error out (eo) pin. the unlock detection block detects the unlock status of the pll frequency synthesizer. the following subsections 16.5.2 to 16.5.4 explain the operations of the phase comparator, charge pump, and unlock detection block respectively. figure 16-4. configurations of phase comparator, charge pump, and unlock detection block reference frequency generator unlock ff pllul flag charge pump phase comparator ( -det) f r f n up dw pll disable signal eo programmable divider 16.5.2 function of phase comparator as shown in figure 16-4, the phase comparator compares the divided frequency output f n of the programmable divider with the reference frequency output f r of the reference frequency generator, and outputs an up request or down request signal. if the divided frequency f n is lower than the reference frequency f r , the phase comparator outputs the up request signal; if f n is higher than f r , it outputs the down request signal. figure 16-5 shows the relationship among the reference frequency f r , divided frequency f n , up request signal, and down request signal. when the pll is disabled, neither the up request nor down request signal is output. the up request and down request signals are respectively input to the charge pump and unlock detection block.
pd17012, 17p012 189 data sheet u10101ej4v0ds figure 16-5. relationship between f r , f n , up, and dw (a) if f n is behind f r in phase f r f n up dw (b) if f n leads f r in phase f r f n up dw (c) if f n and f r are in phase f r f n up dw (d) if f n is lower than f r in frequency f r f n up dw 16.5.3 charge pump as shown in figure 16-4, the charge pump outputs the up request signal or down request signal from the phase comparator to the error out (eo) pin. therefore, the relationship between the output of the error out pin, divided frequency f n , and reference frequency f r is as follows. when reference frequency f r > divided frequency f n : low-level output when reference frequency f r < divided frequency f n : high-level output when reference frequency f r = divided frequency f n : floating
pd17012, 17p012 190 data sheet u10101ej4v0ds 16.5.4 unlock detection block as shown in figure 16-4, the unlock detection block detects the unlock status of the pll frequency synthesizer by using the up request or down request signal from the phase comparator. because either of the up request or down request signal outputs a low level in the unlock status, this low- level signal is used to detect the unlock status. in the unlock status, the unlock flip-flop (ff) is set to 1. the unlock status is detected by the pll unlock ff judgement register (refer to 16.5.5 ). the unlock ff is set at the cycle of reference frequency f r selected at that time. when the contents of the pll unlock ff judge register are read (by the peek instruction), the unlock ff is reset (read & reset). therefore, the unlock ff must be detected at a cycle longer than the cycle 1/f r of the reference frequency f r . 16.5.5 configuration and function of unlock ff judge register this register is a read-only register and is reset when its contents are read to the window register by the peek instruction. because the unlock ff is set at the cycle of reference frequency f r , the contents of the pll unlock ff judge register must be written to the window register at a cycle longer than the cycle 1/f r of the reference frequency f r . the delay of the phase comparator up/down request signal is fixed to between 0.8 s and 1.0 s. name flag symbol b 3 0 b 2 0 b 1 0 b 0 p l l u l address 05h read/ write 0 1 detects status of unlock ff unlock ff = 0: pll lock status unlock ff = 1: pll unlock status power-on clock stop ce 0 0 0 undefined retained retained pll unlock ff judge register fixed to 0 after reset r & reset
pd17012, 17p012 191 data sheet u10101ej4v0ds 16.6 pll disabled status the pll frequency synthesizer stops operation (is disabled) while the ce pin (pin 7) is low. when the pll is disabled by the pll reference clock select register, the pll frequency synthesizer also stops operation. table 16-2 shows the operation of each block under each pll disable condition. when the vcol and vcoh pins are disabled by the pll mode select register, only the vcol and vcoh pins are internally pulled down, and the other blocks operate. because the pll reference clock select register and pll mode select register are not initialized (but hold the previous status) on ce reset, they are restored to the original status when the ce pin has once gone low and then back high again after the pll has been disabled. to disable the pll on ce reset, therefore, initialize these registers in the program. the pll is disabled at power-on reset. table 16-2. operation of blocks under pll disable conditions condition ce pin = low level ce pin = high level (pll disabled) pll reference clock select register = 1111b pll mode select register = 0000b blocks (pll disabled) (vcoh, vcol disabled) vcol and internally pulled down internally pulled down internally pulled down vcoh pins programmable stops division stops division operates counter reference frequency stops output stops output operates generator phase comparator stops output stops output operates charge pump floats error out pins floats error out pins operates however, usually outputs low level because there is no input. 16.7 using pll frequency synthesizer to control the pll frequency synthesizer, the following data is necessary. (1) division mode: direct division (mf), pulse swallow (hf, vhf) (2) pin used: vcol, vcoh (3) reference frequency: f r (4) division ratio: n the following subsections 16.7.1 to 16.7.3 explain how to set the pll data in each division mode (mf, hf, and vhf).
pd17012, 17p012 192 data sheet u10101ej4v0ds 16.7.1 direct division mode (mf) (1) selecting division mode select the direct division mode by using the pll mode select register. (2) pin used when the direct division mode is selected, the vcol pin is enabled to operate. (3) setting reference frequency f r set the reference frequency by using the pll reference clock select register. (4) calculating division value n calculate as follows: f vcol n = f r where, f vcol : input frequency of vcol pin f r : reference frequency (5) example of setting pll data how to set the data to receive broadcasting in the following mw band is explained below. reception frequency: 1,422 khz (mw band) reference frequency: 9 khz intermediate frequency: +450 khz division value n: f vcol 1,422 + 450 n = = = 208 (decimal) f r 9 = 0d0h (hexadecimal) set data to the pll data register (pllr: peripheral address 41h), pll mode select register (rf address 21h), and pll reference clock select register (rf address 31h) as follows. pll data register (rllr) 0 0 0 0 0 1 1 0 1 d 0 0 0 0 0 don t care 0 0 0 1 mf 1 1 0 1 9 khz pll mode select register pll reference clock select register
pd17012, 17p012 193 data sheet u10101ej4v0ds 16.7.2 pulse swallow mode (hf) (1) selecting division mode select the pulse swallow mode by using the pll mode select register. (2) pin used when the pulse swallow mode is selected, the vcol pin is enabled to operate. (3) setting reference frequency f r set the reference frequency by using the pll reference clock select register. (4) calculating division value n calculate as follows: f vcol n = f r where, f vcol : input frequency of vcol pin f r : reference frequency (5) example of setting pll data how to set the data to receive broadcasting in the following sw band is explained below. reception frequency: 25.50 mhz (sw band) reference frequency: 5 khz intermediate frequency: +450 khz division value n: f vcol 25,500 + 450 n = = = 5190 (decimal) f r 5 = 1446h (hexadecimal) set data to the pll data register (pllr: peripheral address 41h), pll mode select register (rf address 21h), and pll reference clock select register (rf address 31h) as follows. pll data register (rllr) 0 0 0 1 1 0 1 0 0 4 0 1 0 0 4 0 1 1 0 6 0 0 1 1 hf 0 0 1 0 5 khz pll mode select register pll reference clock select register
pd17012, 17p012 194 data sheet u10101ej4v0ds 16.7.3 pulse swallow mode (vhf) (1) selecting division mode select the pulse swallow mode by using the pll mode select register. (2) pin used when the pulse swallow mode is selected, the vcoh pin is enabled to operate. (3) setting reference frequency f r set the reference frequency by using the pll reference clock select register. (4) calculating division value n calculate as follows: f vcoh n = f r where, f vcoh : input frequency of vcoh pin f r : reference frequency (5) example of setting pll data how to set the data to receive broadcasting in the following fm band is explained below. reception frequency: 100.0 mhz (fm band) reference frequency: 25 khz intermediate frequency: +10.7 mhz division value n: f vcoh 100.0 + 10.7 n = = = 4428 (decimal) f r 0.025 = 114ch (hexadecimal) set data to the pll data register (pllr: peripheral address 41h), pll mode select register (rf address 21h), and pll reference clock select register (rf address 31h) as follows. pll data register (rllr) 0 0 0 1 1 0 0 0 1 1 0 1 0 0 4 1 1 1 0 c 0 0 1 0 vhf 0 1 1 0 25 khz pll mode select register pll reference clock select register
pd17012, 17p012 195 data sheet u10101ej4v0ds 16.8 status on reset 16.8.1 on power-on reset the pll is disabled on power-on reset because the pll reference clock select register is initialized to 1111b. 16.8.2 on execution of clock stop instruction the pll is disabled when the ce pin goes low. 16.8.3 on ce reset (1) ce reset after execution of clock stop instruction the pll is disabled because the pll reference clock select register is initialized to 1111b by the clock stop instruction. (2) ce reset without clock stop instruction executed because the pll reference clock select register retains the previous status, the previous status is restored as soon as the ce pin has gone high. 16.8.4 in halt status the set status is retained if the ce pin is high.
pd17012, 17p012 196 data sheet u10101ej4v0ds 17. frequency counter 17.1 outline of frequency counter figure 17-1 illustrates the frequency counter. the frequency counter has an if counter function to count the intermediate frequency (if) of an external input signal and an external gate counter (fcg: frequency counter for external gate signal) to detect the pulse width of an external input signal. the if counter function counts the frequency input to the p1b 3 /fmifc or p1b 2 /amifc pin at fixed intervals (1 ms, 4 ms, 8 ms, or open) by using a 16-bit counter. the external gate counter function counts the frequency of the internal clock (1 khz, 100 khz, 900 khz) from the rising to the falling of the signal input to the p0b 3 /fcg 1 or p0b 2 /fcg 0 pin. the if counter and external gate counter functions cannot be used at the same time. figure 17-1. outline of frequency counter i/o select block gate time control block start/stop control block if counter (16 bits) p0b 3 /fcg 1 fcgch1 flag fcgch0 flag ifcck1 flag ifcck0 falg ifcstrt flag dbf ifcg flag ifcres flag ifcmd1 flag ifcmd0 flag p0b 2 /fcg 0 p1b 3 /fmifc p1b 2 /amifc remarks 1. fcgch1 and fcgch0 (bits 1 and 0 of the fcg channel select register; refer to figure 17-4 ) select the pin used for the external gate counter function. 2. ifcmd1 and ifcmd0 (bits 3 and 2 of the if counter mode select register; refer to figure 17-3 ) select the if counter or external gate counter function. 3. ifcck1 and ifcck0 (bits 1 and 0 of the if counter mode select register; refer to figure 17-3 ) select the gate time of the if counter function and the reference frequency of the external gate counter function. 4. ifcstrt (bit 1 of the if counter control register; refer to figure 17-6 ) control starting of the if counter and external gate counter functions. 5. ifcg (bit 0 of the if counter gate judge register; refer to figure 17-7 ) detects opening/closing the gate of the if counter function. 6. ifcres (bit 0 of the if counter control register; refer to figure 17-6 ) reset the count value of the if counter.
pd17012, 17p012 197 data sheet u10101ej4v0ds 17.2 input/output select block and gate time control block figure 17-2 shows the configuration of the input/output select block and gate time control block. the input/output select block consists of an if counter input select block and fcg i/o select block. the if counter input select block selects whether the frequency counter is used as an if counter or an external gate counter, by using the if counter mode select register. when the frequency counter is used as the if counter, either p1b 3 /fmifc or p1b 2 /amifc pin and a count mode are selected. the pin not used for the if counter is used as a general-purpose input port pin. the fcg i/o select block selects a pin to be used from either the p0b 3 /fcg 1 or p0b 2 /fcg 0 pin by using the fcg channel select register, when the frequency counter is used as the external gate counter. the pin not used is used as a general-purpose i/o port pin. when using the frequency counter as the external gate counter, the pin to be used must be set in the input mode by using the port 0b bit i/o select register. this is because the pin is set in the general-purpose output port mode if it is set in the output mode even if the external gate counter function is selected by the if counter mode select register and fcg channel select register. the gate time control block selects gate time by using the if counter mode select register when the frequency counter is used as the if counter, or a count frequency when the frequency counter is used as the external gate counter. figure 17-3 shows the configuration of the if counter mode select register. figure 17-4 shows the configuration of the fcg channel select register. figure 17-2. configuration of i/o select block and gate time control block p0b 3 /fcg 1 p0b 2 /fcg 0 p1b 3 /fmifc p1b 2 /amifc input port fmifc amifc gate signal generator frequency generator selector frequency gate signal to start/stop control block i/o port fcgch1 flag fcgch0 flag ifcmd1 flag ifcmd0 flag fcg ifcck1 flag ifcck0 flag selector
pd17012, 17p012 198 data sheet u10101ej4v0ds figure 17-3. configuration of if counter mode select register caution the if counter and external gate counter functions cannot be used at the same time. name flag symbol b 3 i f c m d 1 b 2 i f c m d 0 b 1 i f c c k 1 b 0 i f c c k 0 address 12h read/write r/w if counter mode select register power-on clock stop ce after reset 0 1 0 1 0 0 1 ms 4 ms 8 ms open 1 khz 100 khz 900 khz 0 khz selects gate time of if counter and reference frequency of external gate counter gate time of if counter reference frequency of external gate counter 0 0 0 0 0 0 1 1 0 0 0 1 0 1 external gate counter (fcg) if counter (amifc pin, amif count mode) if counter (fmifc pin, fmif count mode) if counter (fmifc pin, amif count mode) selects function of if counter or external gate counter 0 0 1 1 retained
pd17012, 17p012 199 data sheet u10101ej4v0ds figure 17-4. configuration of fcg channel select register name flag symbol b 3 0 b 2 0 b 1 f c g c h 1 b 0 f c g c h 0 address 24h read/write r/w fcg channel select register 0 1 0 1 p0b 2 /fcg 0 pin p0b 3 /fcg 1 pin fcg not used (general-purpose i/o port) fcg not used (general-purpose i/o port) fixed to 0 selects pin used for fcg 0 0 1 1 power-on clock stop ce after reset 1 1 001 1 retained
pd17012, 17p012 200 data sheet u10101ej4v0ds 17.3 start/stop control block and if counter 17.3.1 configuration of start/stop control block and if counter figure 17-5 shows the configuration of the start/stop control block and if counter. the start/stop control block starts the frequency counter or detects the end of counting. the counter is started by the if counter control register. the end of counting is detected by the if counter gate judge register. when the external gate counter function is used, however, the end of counting cannot be detected by the if counter gate judge register. figure 17-6 shows the configuration of the if counter control register. figure 17-7 shows the configuration of the if counter gate judge register. 17.3.2 and 17.3.3 describe the gate operation when the if counter function is selected and that when the external gate counter function is selected. the if counter is a 16-bit binary counter that counts up the input frequency when the if counter function or external gate counter function is selected. when the if counter function is selected, the frequency input to a selected pin is counted while the gate is opened by an internal gate signal. the frequency count is counted without alteration in the amif count mode. in the fmif counter mode, however, the frequency input to the pin is halved and counted. when the external gate counter function is selected, the internal frequency is counted while the gate is opened by the signal input to the pin. when the if counter counts up to ffffh, the following input becomes 0000h, and then counting continues. the count value is read by the if counter data register (ifc) via data buffer. the count value is reset by the if counter control register. figure 17-8 shows the configuration of the if counter data register. figure 17-5. configuration of start/stop control block and if counter start/stop control if counter (16 bits) 16 if counter data register (ifc) dbf ifcstrt flag ifcres flag ifcg flag gate signal frequency from gate time select block 16 res
pd17012, 17p012 201 data sheet u10101ej4v0ds figure 17-6. configuration of if counter control register the if counter control register is controlled by writing the contents of the window register to it using the poke instruction. when the contents of the if counter are read by the peek instruction, 0 is read in the window register. name flag symbol b 3 0 b 2 0 b 1 i f c s t r t b 0 i f c r e s address 23h read/write w if counter control register 0 1 nothing is affected resets counter resets data of if counter and external gate counter nothing is affected starts counter fixed to 0 starts if counter and external gate counter 0 1 power-on clock stop ce after reset 0 0 000 0 retained
pd17012, 17p012 202 data sheet u10101ej4v0ds figure 17-7. configuration of if counter gate judge register cautions 1. do not read the contents of the if counter data register (ifc) to the data buffer while the ifcg flag is set to 1. 2. the gate of the external gate counter cannot be opened or closed by the ifcg flag. use the ifcstrt flag to open or close the gate. remark r: retained name flag symbol b 3 0 b 2 0 b 1 0 b 0 i f c g address 04h read/write r if counter gate judge register 0 1 detects opening/closing of gate of frequency counter when if counter function is selected when external gate counter function is selected fixed to 0 sets ifcstrt flag to 1 and is set to 1 until gate is closed sets ifcstrt flag to 1 and is set to 1 while gate is open, regardless of input of p0b 2 /fcg 0 and p0b 3 /fcg 1 pins power-on clock stop ce after reset 0 0 r 000
pd17012, 17p012 203 data sheet u10101ej4v0ds 17.3.2 operation of gate when if counter function is selected (1) when gate time of 1, 4, or 8 ms is selected the gate is opened for 1, 4, or 8 ms from the rising of the internal 1 khz signal after the ifcstrt flag has been set to 1, as illustrated below. while this gate is open, the frequency input from a selected pin is counted by a 16-bit counter. when the gate is closed, the ifcg flag is cleared to 0. the ifcg flag is automatically set to 1 when the ifcstrt flag is set. gate is actually opened at this point count period (ifcg flag = 1) ifcstrt flag is set ifcg flag is set at this point end of counting ifg flag is cleared h internal 1 khz 1 ms gate time 4 ms 8 ms l open close (2) when gate is open if opening of the gate is selected by the ifcck1 and ifcck0 flags, the gate is opened as soon as its opening has been selected, as illustrated below. if the counter is started by using the ifcstrt flag while the gate is open, the gate is closed after an undefined amount of time. to open the gate, therefore, do not set the ifcstrt flag to 1. however, the counter can be reset by the ifcres flag. sets ifcck1 = ifcck0 = 1 gate is actually opened at this point. if gate is opened while ifcg flag is 1, it is closed after an undefined amount of time count period gate is closed after an undefined amount of time if ifcstrt flag is set during this period h internal 1 khz l open close gate the gate is opened or closed in the following two ways when opening the gate is selected as the gate time.
pd17012, 17p012 204 data sheet u10101ej4v0ds (a) resetting the gate to other than open by using ifcck1 and ifcck0 flags ifcck1 = ifcck0 = 1 count period resetting the gate to other than open by ifcck1 and ifcck0 flags open gate close (b) unselect pin used by using ifcmd1 and ifcmd0 flags in this way, the gate remains open, and counting is stopped by disabling input from the pin. gate open close sets ifcck1 = ifcck0 = 1 count period sets ifcmd1 = ifcmd0 = 0 (fcg) fmifc and amifc pins are unselected and count signal cannot be input 17.3.3 gate operation when external gate counter function is selected the gate is opened from the rising to the next rising of the signal input to a selected pin after the ifcstrt flag has been set to 1, as illustrated below. while the gate is open, the internal frequency (1 khz, 100 khz, 900 khz) is counted by a 16-bit counter. the ifcg flag is set to 1 from the rising to the next rising of the external signal after the ifcstrt flag has been set. in other words, the opening or closing of the gate cannot be detected by the ifcg flag when the external gate counter function is selected. h l open close external signal gate count period gate is opened at this point end of counting ifcg flag is ? ifcstrt flag 1 if reset and started while gate is open h l open close external signal gate count period count period ifcstrt flag 1 gate is opened at this point end of counting ifcg flag is 0 ifcstrt flag 1
pd17012, 17p012 205 data sheet u10101ej4v0ds figure 17-8. configuration of if counter data register data buffer dbf3 dbf2 name if counter data register symbol ifc peripheral address 43h dbf1 dbf0 b 3 b 2 b 1 b 0 b 6 b 5 b 4 b 10 b 9 b 8 b 7 b 13 b 12 b 15 b 14 b 11 peripheral register 0 transfer data valid data get can be executed put changes nothing 16 count value of frequency counter x 2 16 ? 1 (ffffh) if counter function fmif count mode of fmifc pin counts rising edge of signal input to p1b 3 /fmifc pin via 1/2 divider amif count mode of amifc pin counts rising edge of signal input to p1b 2 /amifc pin amif count mode of fmifc pin counts rising edge of signal input to p1b 3 /fmifc pin external gate counter function counts rising edge of internal reference frequency signal from rising edge to next rising edge of signal input to p0b 2 /fcg 0 or p0b 3 /fcg 1 pin the if counter is cleared to 0000h when its count value has reached ffffh, and then continues counting.
pd17012, 17p012 206 data sheet u10101ej4v0ds 17.4 using if counter function the following subsections 17.4.1 through 17.4.3 explain how to use the hardware of the if counter function, program example, and count error. 17.4.1 using hardware of if counter figure 17-9 shows the block diagram illustrating how the p1b 3 /fmifc and p1b 2 /amifc pins are used. table 17-1 shows the range of the frequencies that can be input to the p1b 3 /fmifc and p1b 2 /amifc pins. because the input pins of the if counter have an internal amplifier, cut off the dc component of the input signal by using capacitor c as shown in figure 17-9. when the p1b 3 /fmifc or p1b 2 /amifc pin is selected as the if counter pin, switch sw turns on, applying a voltage of about 1/2v dd to each pin. if the voltage has not risen to a sufficient intermediate level at this time, the ac amplifier does not operate normally, and consequently, the if counter does not correctly operate. therefore, make sure that a sufficiently long wait time elapses from the time each pin is selected as an if counter until counting is started. figure 17-9. function of each if counter pin to internal counter sw r fmifc amifc c external frequency table 17-1. input frequency range of if counter input pin input frequency input amplitude (mhz) (v p-p ) p1b 3 /fmifc 5 to 15 0.3 fmif mode 10.5 to 10.9 0.1 p1b 3 /fmifc 0.3 to 1 0.3 amif mode p1b 2 /amifc 0.3 to 1 0.3 amif mode 0.44 to 0.46 0.1
pd17012, 17p012 207 data sheet u10101ej4v0ds 17.4.2 program example of if counter function a program example of the if counter function is shown below. as shown in this example, a wait time must elapse after an instruction that selects the p1b 3 /fmifc or p1b 2 / amifc pin as the if counter pin has been executed before counting is started. this is because the internal ac amplifier may not operate normally immediately after each pin has been selected, as explained in 17.4.1 . example to count frequency on p1b 3 /fmifc pin (gate time: 8 ms) initflg ifcmd1, not ifcmd0, ifcck1, not ifcck0 ; selects fmifc pin and sets gate time to 8 ms. wait ; internal ac amplifier stabilization time loop: skt1 ifcg ; detects opening/closing of gate. br read ; branches to read: when gate is closed. processing a ; do not read data of if counter by this processing a. br loop read: get dbf, ifc ; reads value of if counter data register to data buffer. 17.4.3 error of if counter the if counter may have a gate time error and a count error. these errors are explained in (1) and (2) below. (1) error of gate time the gate time of the if counter is created by dividing the 4.5 mhz system clock. therefore, if the system clock deviates +x ppm, the gate time deviates ? x ppm. (2) count error the if counter counts the frequency at the rising edge of an input signal. if a high level is input to the pin when the gate is opened, therefore, one excess pulse is counted. however, counting is not performed because of the status of the pin when the gate is closed. therefore, a count error of +1, ? 0 may occur.
pd17012, 17p012 208 data sheet u10101ej4v0ds 17.5 error of external gate counter the external gate counter has an internal frequency error and count error, as described in (1) and (2) below. (1) internal frequency error the internal frequency of the external gate counter is created by dividing the 4.5 mhz system clock frequency. therefore, if this frequency has an error of +x ppm, the internal frequency accordingly has an error of +x ppm. (2) count error the external gate counter counts the frequency at the rising edge of the internal frequency. therefore, if the internal frequency is at low level when the gate is opened (when the input signal of the pin rises), one extra pulse is counted. however, this extra pulse may not be counted, depending on the count level of the internal frequency, when the gate is closed (when the input signal of the pin rises next time). therefore, the count error is +1, ? 0 . 17.6 status on reset 17.6.1 on power-on reset the p1b 3 /fmifc and p1b 2 /amifc pins are set in the general-purpose input port mode. the p0b 3 /fcg 1 and p0b 2 /fcg 0 pins are set in the general-purpose i/o port mode. 17.6.2 on execution of clock stop instruction the p1b 3 /fmifc and p1b 2 /amifc pins are set in the general-purpose input port mode. the p0b 3 /fcg 1 and p0b 2 /fcg 0 pins are set in the general-purpose i/o port mode. 17.6.3 on ce reset the p1b 3 /fmifc, p1b 2 /amifc, p0b 3 /fcg 1 , and p0b 2 /fcg 0 pins retain the previous status. 17.6.4 in halt status the p1b 3 /fmifc, p1b 2 /amifc, p0b 3 /fcg 1 , and p0b 2 /fcg 0 pins retain the status immediately before the halt status was set.
pd17012, 17p012 209 data sheet u10101ej4v0ds 18. beep 18.1 general figure 18-1 shows the outline of beep. beep outputs 1 khz, 3 khz, 200 hz, or 9 khz clock from the p0b 0 /beep 0 and p0b 1 /beep 1 pins. figure 18-1. outline of beep remarks 1. p0bbio1 and p0bbio0 (bits 1 and 0 of the port 0b bit i/o select register; refer to figure 18-2 ) set the p0b 1 /beep 1 and p0b 0 /beep 0 pins in the input/output mode. 2. beep1sel and beep0sel (bits 1 and 0 of the beep select register; refer to figure 18-3 ) set the p0b 1 / beep 1 and p0b 0 /beep 0 pin in the general-purpose output port or beep output mode. 3. beep1ck1, beep1ck0, beep0ck1, and beep0ck0 (bits 3 to 0 of the beep clock select register; refer to figure 18-4 ) set the output frequencies of beep 1 and beep 0 . p0bbio1 flag beep1sel flag p0bbio0 flag beep0sel flag beep1ck1 flag beep1ck0 flag clock generation block beep0ck1 flag beep0ck0 flag clock select block output select block output select block i/o select block i/o select block clock select block output latch output latch p0b 1 /beep 1 p0b 0 /beep 0 1 khz 3 khz 200 hz 9 khz
pd17012, 17p012 210 data sheet u10101ej4v0ds 18.2 i/o select block and output select block the i/o select block sets the p0b 1 /beep 1 and p0b 0 /beep 0 pins in the input or output mode by using the port 0b bit i/o select register. these pins must be set in the output mode when they are used as the beep pins. the output select block sets the p0b 1 /beep 1 and p0b 0 /beep 0 pins in the general-purpose output port or beep output mode by using the beep select register. figure 18-2 shows the configuration and function of the port 0b bit i/o select register. figure 18-3 shows the configuration and function of the beep select register. figure 18-2. configuration of port 0b bit i/o select register name flag symbol b 3 b 2 b 1 b 0 address 36h read/ write 0 1 sets input or output of port sets p0b 0 /beep 0 pin in input mode sets p0b 0 /beep 0 pin in output mode power-on clock stop ce 0 0 0 0 0 0 0 0 0 0 0 0 port 0b bit i/o select register sets input or output of port sets p0b 1 /beep 1 pin in input mode sets p0b 1 /beep 1 pin in output mode sets input or output of port sets p0b 2 /fcg 0 pin in input mode sets p0b 2 /fcg 0 pin in output mode sets input or output of port sets p0b 3 /fcg 1 pin in input mode sets p0b 3 /fcg 1 pin in output mode 0 1 0 1 0 1 p 0 b b i o 3 p 0 b b i o 2 p 0 b b i o 1 p 0 b b i o 0 after reset r/w
pd17012, 17p012 211 data sheet u10101ej4v0ds figure 18-3. configuration of beep select register name flag symbol b 3 b 2 b 1 b 0 address 15h read/ write 0 1 selects general-purpose i/o port or beep uses p0b 0 /beep 0 pin as general-purpose i/o port uses p0b 0 /beep 0 pin as beep power-on clock stop ce 000 0 0 0 0 0 beep select register selects general-purpose i/o port or beep uses p0b 1 /beep 1 pin as general-purpose i/o port uses p0b 1 /beep 1 pin as beep fixed to 0 0 1 00b e e p 1 s e l b e e p 0 s e l after reset r/w
pd17012, 17p012 212 data sheet u10101ej4v0ds 18.3 clock select block and clock generator block the clock select block selects the output frequencies of the beep 1 and beep 0 pins by using the beep clock select register. the clock generator block generates the clock to be output to the beep 1 and beep 0 pins. the clock frequency to be generated is 1 khz, 3 khz, 200 hz, or 9 khz. figure 18-4 shows the configuration and function of the beep clock select register. figure 18-4. configuration of beep clock select register name flag symbol b 3 b 2 b 1 b 0 address 25h read/ write 0 0 1 1 0 1 0 1 sets output frequency of beep 1 1 khz 3 khz 200 hz 9 khz 0 0 1 1 0 1 0 1 sets output frequency of beep 0 1 khz 3 khz 200 hz 9 khz power-on clock stop ce 0 0 0 0 0 0 0 0 beep clock select register retained b e e p 1 c k 1 after reset b e e p 1 c k 0 b e e p 0 c k 1 b e e p 0 c k 0 r/w
pd17012, 17p012 213 data sheet u10101ej4v0ds 18.4 output waveform of beep the duty cycle of the output waveform of beep is 50% except when f = 1 khz. the output waveform is shown below. 55.6 s f = 9 khz f = 3 khz f = 1 khz f = 200 hz 55.6 s 166.7 s 166.7 s 555.6 s 444.4 s 2.5 ms 2.5 ms ? ? ? remark f: output frequency of beep 18.5 status on reset 18.5.1 at power-on reset the p0b 0 /beep 0 and p0b 1 /beep 1 pins are set in the general-purpose input port mode. 18.5.2 at clock stop the p0b 0 /beep 0 and p0b 1 /beep 1 pins are set in the general-purpose input port mode. 18.5.3 at ce reset the p0b 0 /beep 0 and p0b 1 /beep 1 pins are set in the general-purpose input port mode.
pd17012, 17p012 214 data sheet u10101ej4v0ds 19. lcd controller/driver the lcd (liquid crystal display) controller/driver can display an lcd of up to 60 dots by outputting segment and common signals in combination. 19.1 configuration of lcd controller/driver figure 19-1 shows the block diagram of the lcd controller/driver. as shown in the figure, the lcd controller/driver consists of a common signal output timing control block, segment signal/key source signal output timing control block, segment signal/general-purpose output port select block, lcd segment register, and key source data register/port ya group register. the following section 19.2 outlines the function of each block. figure 19-1. outline of lcd controller/driver common signal output timing segment signal/ general-purpose output port select block p2hsel flag p2gsel flag p2fsel flag p2esel flag pyasel flag dbf ksen flag lcden flag lcd segment resister (data memory space) key source data register/ port ya group register segment signal/ key source signal output timing control block com 2 com 1 com 0 lcd 19 /p2h 0 lcd 18 /p2g 0 lcd 17 /p2f 0 lcd 16 /p2e 0 lcd 15 /ks 15 /pya 15 lcd 0 /ks 0 /pya 0 ....... remarks 1. p2hsel, p2gsel, p2fsel, and p2esel (bits 3 to 0 of lcd port select register; refer to figure 19-7 ) set the output of the lcd 19 /p2h 0 , lcd 18 /p2g 0 , lcd 17 /p2f 0 , and lcd 16 /p2e 0 in the lcd segment signal output or general-purpose output port mode. 2. pyasel (bit 0 of lcd mode select register; refer to figure 19-9 ) sets the output of the lcd 15 /ks 15 / pya 15 through lcd 0 /ks 0 /pya 0 pins in the lcd segment signal output or general-purpose output port mode. 3. lcden (bit 1 of lcd mode select register; refer to figure 19-9 ) turns on/off all lcd displays. 4. ksen (bit 2 of lcd mode select register; refer to figure 19-9 ) sets the output of the key source signal.
pd17012, 17p012 215 data sheet u10101ej4v0ds 19.2 functional outline of lcd controller/driver the lcd controller/driver can display up to 60 dots by using a combination of common signal output pins (com 2 to com 0 ) and segment signal output pins (lcd 19 /p2h 0 to lcd 0 /ks 0 /pya 0 ). figure 19-2 shows the relationship between common signal output pins, segment signal output pins, and display dots. as shown in this figure, three dots can be displayed at the intersections between one segment line and the com 2 to com 0 pins. the driving mode is 1/3 duty, 1/2 bias, and the drive voltage is supply voltage v dd . the segment signal output pins (lcd 19 /p2h 0 to lcd 0 /ks 0 /pya 0 ) can also be used as general-purpose output port pins. when these pins are used as general-purpose output port pins, ports 2h (lcd 19 /p2h 0 ), 2g (lcd 18 /2g 0 ), 2f (lcd 17 /p2f 0 ), 2e (lcd 16 /p2e 0 ), and ya (lcd 15 /ks 15 /pya 15 to lcd 0 /ks 0 /pya 0 ) can be independently used. of the segment signal output pins, the lcd 15 /ks 15 /pya 15 to lcd 0 /ks 0 /pya 0 pins are also used as key source signal output pins. the key source signals and lcd segment signals are output by means of time-division multiplexing. for details of the general-purpose output ports, refer to 10. general-purpose ports . for details of the key source signals, refer to 20. key source controller/decoder . the following subsections 19.2.1 through 19.2.5 outline the function of each block of the lcd controller/ driver. figure 19-2. common signal output, segment signal output, and display dots com 1 pin com 2 pin display dot segment signal output pin (lcd n ) com 0 pin 19.2.1 lcd segment register the lcd segment register sets dot data that is used to turn on/off the lcd. because this register is mapped in the data memory, it can be controlled by any data memory manipulation instruction. when the segment signal output pins are used as general-purpose output port pins, this register sets output data. for details, refer to 19.3 . 19.2.2 common signal output timing control block the common signal output timing control block controls the common signal output timing of the com 2 , com 1 , and com 0 pins. these pins output a low level when the lcd is not displayed. whether the lcd is displayed or not is selected by the lcd mode select register (rf address 10h). for details, refer to 19.4 .
pd17012, 17p012 216 data sheet u10101ej4v0ds 19.2.3 segment signal/key source signal output timing control block the segment signal/key source signal output timing control block controls the segment signal output timing of the lcd 19 /p2h 0 through lcd 0 /ks 0 /pya 0 pins. these pins output a low level when the lcd is not displayed. whether the lcd is displayed or not is selected by the lcd mode select register. the segment signal/key source signal output timing control block controls the timing of the segment and key source signals output from the lcd 15 /ks 15 through lcd 0 /ks 0 pins. whether the key source signals are used or not is selected by the lcd mode select register. for details, refer to 19.5 . 19.2.4 segment signal/general-purpose output port select block the segment signal/general-purpose output port select block selects whether each segment signal output pin is used for lcd display (to output a segment signal) or as a general-purpose output port pin. this selection is made by using the p2hsel to p2esel flags of lcd port select register and pyasel flag of lcd mode select register. for details, refer to 19.4 and 19.5 . 19.2.5 key source data register/port ya group register the key source data register/port ya group register sets the key source output data that is output from the lcd 15 /ks 15 /pya 15 to lcd 0 /ks 0 /pya 0 pins. the key source signal output data is set by the key source data register (ksr: peripheral address 42h) via the data buffer. for details, refer to 20. key source controller/decoder .
pd17012, 17p012 217 data sheet u10101ej4v0ds 19.3 lcd segment register the lcd segment register specifies whether each dot on the lcd is turned on or off. 19.3.1 configuration of lcd segment register figure 19-3 shows the location and configuration of the lcd segment register in the data memory. figure 19-3. location and configuration of lcd segment register in data memory 0 lcdd15 1 lcdd14 2 lcdd13 3 lcdd12 4 lcdd11 5 lcdd10 6 lcdd9 7 lcdd8 8 lcdd7 9 lcdd6 a lcdd5 b lcdd4 c lcdd19 lcdd3 d lcdd18 lcdd2 e lcdd17 lcdd1 f lcdd16 lcdd0 5 6 lcdd15 dbf b 3 b 2 b 1 b 0 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 bank0 bank1 bank2 lcd segment register data memory column address system register 0123456789abcdef bcdef bcdef row address
pd17012, 17p012 218 data sheet u10101ej4v0ds 19.3.2 function of lcd segment register figure 19-4 shows the relation of 1 nibble (4 bits) of the lcd segment register and lcd display dots. as shown in this figure, the lower 3 bits of display data (on/off data) in 1 nibble of the lcd segment register can be set. the lcd display dot corresponding to a bit that is set to 1 is turned on, and the dot corresponding to a bit that is reset to 0 is turned off. the highest one bit can be used as data memory, however data should be set carefully because the address is the same. lcdd19 to lcdd16 of the lcd segment register also set output data when the lcd 19 /p2h 0 to lcd 16 /p2e 0 pins are used as output port pins. in this case, output data is set to the least significant bit. the higher 3 bits can be used as data memory, however data setting requires caution because the addresses are the same. when lcd display is not used, lcdd15 to lcdd0 can be used as normal data memory. figure 19-5 shows the relationship between each lcd segment register and lcd display dots that are turned on/off. figure 19-4. relationship of 1 nibble of lcd segment register and lcd display dots lcd segment register lcd n pin can be used as data memory m b 3 b 2 b 2 b 1 b 0 b 1 b 0 address bit com 2 pin com 1 pin com 0 pin
pd17012, 17p012 219 data sheet u10101ej4v0ds figure 19-5. relationship between lcd display dot, output of each pin and each data setting register key source pin no. lcd function 80 pin 64 pin (46) (38) lcdd19 (5ch) (47) (39) lcdd18 (5dh) (48) (40) lcdd17 (5eh) (49) (41) lcdd16 (5fh) (50) (42) lcdd15 (60h) (52) (43) lcdd14 (61h) (53) (44) lcdd13 (62h) (55) (45) lcdd12 (63h) (56) (46) lcdd11 (64h) (57) (47) lcdd10 (65h) (58) (48) lcdd9 (66h) (59) (49) lcdd8 (67h) (60) (50) lcdd7 (68h) (61) (51) lcdd6 (69h) (62) (52) lcdd5 (6ah) (63) (53) lcdd4 (6bh) (64) (54) lcdd3 (6ch) (65) (55) lcdd2 (6dh) (66) (56) lcdd1 (6eh) (67) (57) lcdd0 (6fh) lcd segment register (ram address bank2) ksr (42h) b 15 b 2 b 1 b 0 com 2 pin com 1 pin com 0 pin 35 : 64 pin 42 : 80 pin b 2 b 1 b 0 b 2 b 1 b 0 b 2 b 1 b 0 b 2 b 1 b 0 b 2 b 1 b 0 b 2 b 1 b 0 b 2 b 1 b 0 b 2 b 1 b 0 b 2 b 1 b 0 b 2 b 1 b 0 b 2 b 1 b 0 b 2 b 1 b 0 b 2 b 1 b 0 b 2 b 1 b 0 b 2 b 1 b 0 b 2 b 1 b 0 b 2 b 1 b 0 b 2 b 1 b 0 b 2 b 1 b 0 b 14 b 13 b 12 b 11 b 10 b 9 b 8 b 7 b 6 b 5 b 4 b 3 b 2 b 1 b 0 b 15 b 14 b 13 b 12 b 11 b 10 b 9 b 8 b 7 b 6 b 5 b 4 b 3 b 2 b 1 b 0 pya (42h) key source data register (peripheral address) port ya group register (peripheral address) general- purpose port pya 0 /ks 0 pya 1 /ks 1 pya 2 /ks 2 pya 3 /ks 3 pya 4 /ks 4 pya 5 /ks 5 pya 6 /ks 6 pya 7 /ks 7 pya 8 /ks 8 pya 9 /ks 9 pya 10 /ks 10 pya 11 /ks 11 pya 12 /ks 12 pya 13 /ks 13 pya 14 /ks 14 pya 15 /ks 15 lcd 0 lcd 1 lcd 2 lcd 3 lcd 4 lcd 5 lcd 6 lcd 7 lcd 8 lcd 9 lcd 10 lcd 11 lcd 12 lcd 13 lcd 14 lcd 15 lcd 16 /p2e 0 lcd 17 /p2f 0 lcd 18 /p2g 0 lcd 19 /p2h 0 36 : 64 pin 44 : 80 pin 37 : 64 pin 45 : 80 pin
pd17012, 17p012 220 data sheet u10101ej4v0ds 19.4 segment signal/general-purpose output port select block figure 19-6 shows the configuration of the segment signal/general-purpose output port select block. this block specifies whether each pin is used as a segment signal output pin or a general-purpose output port pin, by using the p2hsel through p2esel flags of the lcd port select register and the pyasel flag of the lcd mode select register. when each flag is 1, the corresponding pin is set in the general-purpose output port mode; when the flag is 0, the pin is set in the segment signal output mode. the lcd 15 /ks 15 /pya 15 to lcd 0 /ks 0 /pya 0 pins can simultaneously output segment signals and key source signals. when port ya is selected, however, port output takes precedence. figure 19-7 shows the configuration and function of the lcd port select register. figure 19-9 shows the configuration and function of the lcd mode select register. figure 19-6. configuration of segment signal/general-purpose output port select block 1 0 1 0 p2hsel flag note pyasel flag port data from bit 0 of lcdd19 note lcd 19 /p2h 0 lcd 16 /p2e 0 from segment signal/key source signal output timing control block segment signal port data from key source data register/ port ya group register from segment signal/key source signal output timing control block segment signal lcd 15 /ks 15 /pya 15 lcd 0 /ks 0 /pya 0 note p2gsel flag and lcdd18 for lcd 18 /p2g 0 pin. p2fsel flag and lcdd17 for lcd 17 /p2f 0 pin. p2esel flag and lcdd16 for lcd 16 /p2e 0 pin.
pd17012, 17p012 221 data sheet u10101ej4v0ds figure 19-7. configuration of lcd port select register name flag symbol b 3 b 2 b 1 b 0 address 11h read/ write 0 1 selects lcd segment signal output pin or general-purpose output port uses lcd 16 /p2e 0 pin as lcd segment pin uses lcd 16 /p2e 0 pin as general-purpose output port pin power-on clock stop ce 0 0 0 0 0 0 retained 0 0 lcd port select register selects lcd segment signal output pin or general-purpose output port uses lcd 17 / p2f 0 pin as lcd segment pin uses lcd 17 /p2f 0 pin as general-purpose output port pin selects lcd segment signal output pin or general-purpose output port uses lcd 18 /p2g 0 pin as lcd segment pin uses lcd 18 /p2g 0 pin as general-purpose output port pin selects lcd segment signal output pin or general-purpose output port uses lcd 19 /p2h 0 pin as lcd segment pin uses lcd 19 /p2h 0 pin as general-purpose output port pin 0 1 0 1 0 1 p 2 h s e l p 2 g s e l p 2 f s e l p 2 e s e l after reset r/w
pd17012, 17p012 222 data sheet u10101ej4v0ds 19.5 common signal output timing control block and segment signal/key source signal output timing control block figure 19-8 shows the configuration of the common signal output timing control block and segment signal/key source signal output timing control block. the common signal output timing control block controls the output timing of the com 2 to com 0 signals. the segment signal/key source signal output timing control block controls the output timing of the segment signals and key source signals of the lcd 19 /p2h 0 through lcd 0 /ks 0 /pya 0 pins. the common and segment signals are output when the lcden flag of the lcd mode select register is 1. by clearing the lcden flag to 0, therefore, all lcd displays can be turned off. the key source signal is output when the ksen flag of the lcd mode select register is 1. when lcd display is not performed, the com 2 to com 0 and lcd 19 /p2h 0 to lcd 0 /ks 0 /pya 0 pins output a low level. figure 19-9 shows the configuration and function of the lcd mode select register. figure 19-8. configuration of the common signal output timing control block and segment signal/key source signal output timing control block port data segment signal port data to segment signal/ general-purpose output port select block to segment signal/ general-purpose output port select block to common signal output pin segment signal segment signal timing control key source data register/ port ya group register lcdd19 | lcdd16 ksen flag lcden flag common signal timing control basic clock for timing control segment signal/ key source signal timing control b 0 b 1 b 2 lcdd15 | lcdd0 b 0 b 1 b 2
pd17012, 17p012 223 data sheet u10101ej4v0ds figure 19-9. configuration of lcd mode select register sets output of key source signal key source off key source on name flag symbol b 3 0 b 2 b 1 b 0 address 10h read/ write 0 1 selects lcd segment output pin and general-purpose output port lcd 0 /ks 0 /pya 0 to lcd 15 /ks 15 /pya 15 pins used as lcd segment lcd 0 /ks 0 /pya 0 to lcd 15 /ks 15 /pya 15 pins used as general-purpose output port power-on clock stop ce 00 0 0 0 0 0 lcd mode select register fixed to 0 0 1 turns on/off all lcd display dots display off (all segment and common signals are low) display on 0 1 retained k s e n l c d e n p y a s e l after reset r/w
pd17012, 17p012 224 data sheet u10101ej4v0ds 19.6 output waveforms of common and segment signals figures 19-10 to 19-12 show the output waveforms of the common and segment signals. figure 19-10 shows the output waveform with the key source signals not output, and figures 19-11 and 19- 12 show the output waveform with the key source signals output. as shown in figure 19-10, the lcd driver outputs signals with a frame frequency of 83 hz at 1/3 duty, 1/2 bias (voltage average mode). as the common signals, three levels of voltages (gnd, 1/2 v dd , and v dd ) each having a phase difference of 1/6 from the others are output from the com 1 and com 0 pins. therefore, voltages in a range of 1/2v dd 1/2 v dd are output. this display mode is called 1/2 bias drive mode. as the segment signals, two levels (0, v dd ) of voltages each having a phase corresponding to a display dot are output from each segment signal output pin. because three display dots (a, b, and c) are turned on/off by one segment pin as shown in figure 19-10, eight types of phases <1> through <8> shown in figure 19-10 are output by combination of each dot, and on and off. each display dot is turned on when the potential difference between the common and segment signals reaches v dd . the duty factor at which each display dot is turned on is 1/3, and the frequency of the lcd clock is 167 hz. this display mode is called 1/3 duty drive mode.
pd17012, 17p012 225 data sheet u10101ej4v0ds figure 19-10. common signal and segment signal output waveform (when key source signal is not output) dot a dot b dot c each segment signal output pin (lcd n ) com 2 pin v dd 1/2 v dd gnd com 1 pin v dd 1/2 v dd gnd com 0 pin v dd 1/2 v dd gnd com 2 pin com 1 pin com 0 pin common signal each segment pin <1> a = off, b = off, c = off <2> a = off, b = off, c = on <3> a = off, b = on, c = off <4> a = off, b = on, c = on <5> a = on, b = off, c = off <6> a = on, b = off, c = on <7> a = on, b = on, c = off <8> a = on, b = on, c = on 2 ms 2 ms 2 ms 2 ms 2 ms 2 ms 2 ms 2 ms 2 ms 2 ms 2 ms 2 ms 2 ms c = on c = on c = on c = on b = on c = on a = on a = on a = on a = on c = on b = on a = on a = on a = on a = on c = on c = on c = on b = on b = on b = on a = on a = on a = on a = on b = on b = on b = on b = on a = on a = on a = on a = on c = on c = on c = on c = on a = on a = on a = on a = on b = on c = on b = on c = on c= on b = on b = on b = on b = on b = on
pd17012, 17p012 226 data sheet u10101ej4v0ds figure 19-11. common signal and segment signal output waveform (when ??is output as key source signal) com 2 pin v dd 1/2 v dd gnd com 1 pin v dd 1/2 v dd gnd com 0 pin v dd 1/2 v dd gnd common signal each segment pin (pin outputting "1" as key source) <1> a = off, b = off, c = off <2> a = off, b = off, c = on <3> a = off, b = on, c = off <4> a = off, b = on, c = on <5> a = on, b = off, c = off <6> a = on, b = off, c = on <7> a = on, b = on, c = off <8> a = on, b = on, c = on 2 ms 2 ms 2 ms 2 ms 2 ms 2 ms 2 ms 2 ms 2 ms 2 ms 2 ms 2 ms 2 ms c = on c = on c = on c = on b = on c = on a = on a = on a = on a = on c = on b = on a = on a = on a = on a = on c = on c = on c = on b = on b = on b = on a = on a = on a = on a = on b = on b = on b = on b = on a = on a = on a = on a = on c = on c = on c = on c = on a = on a = on a = on a = on b = on c = on b = on c = on c = on b = on b = on b = on b = on b = on dot a dot b dot c each segment signal output pin (lcd n ) com 2 pin com 1 pin com 0 pin
pd17012, 17p012 227 data sheet u10101ej4v0ds figure 19-12. common signal and segment signal output waveform (when 0 is output as key source signal) com 2 pin v dd 1/2 v dd gnd com 1 pin v dd 1/2 v dd gnd com 0 pin v dd 1/2 v dd gnd common signal each segment pin (pin outputting "0" as key source) <1> a = off, b = off, c = off <2> a = off, b = off, c = on <3> a = off, b = on, c = off <4> a = off, b = on, c = on <5> a = on, b = off, c = off <6> a = on, b = off, c = on <7> a = on, b = on, c = off <8> a = on, b = on, c = on 2 ms 2 ms 2 ms 2 ms 2 ms 2 ms 2 ms 2 ms 2 ms 2 ms 2 ms 2 ms 2 ms c = on c = on c = on c = on b = on c = on a = on a = on a = on a = on c = on b = on a = on a = on a = on a = on c = on c = on c = on b = on b = on b = on a = on a = on a = on a = on b = on b = on b = on b = on a = on a = on a = on a = on c = on c = on c = on c = on a = on a = on a = on a = on b = on c = on b = on c = on c = on b = on b = on b = on b = on b = on dot a dot b dot c each segment signal output pin (lcd n ) com 2 pin com 1 pin com 0 pin
pd17012, 17p012 228 data sheet u10101ej4v0ds 19.7 using lcd controller/driver figure 19-13 shows an example of wiring an lcd panel. an example of a program that turns on a 7-segment lcd panel by using the lcd 0 to lcd 3 pins as shown in figure 19-13 is shown below. example pmn0 mem 0.01h ; preset memory number and bk data storage area ch flg dbf0.2 ; symbol definition of least significant bit of dbf as ?h?display flag lcddata: ; display table data ; b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 ; corresponds to lcd segment register ; ?e agd bc ; corresponds to lcd group register dw 0000000000000000b ; blank dw 0000000000000011b ; 1 dw 0000000101110010b ; 2 dw 0000000001110011b ; 3 dw 0000001000100011b ; 4 dw 0000001001110001b ; 5 dw 0000001101110001b ; 6 dw 0000001001000011b ; 7 dw 0000001101110011b ; 8 dw 0000001001110011b ; 9 dw 0000001101100011b ; a dw 0000001101110011b ; b dw 0000001101010000b ; c dw 0000001101010011b ; d dw 0000001101110000b ; e dw 0000001101100010b ; f clr1 pyasel mov rpl, #1110b mov ar3, #.dl.lcddata shr 12 and 0fh mov ar2, #.dl.lcddata shr 8 and 0fh mov ar1, #.dl.lcddata shr 4 and 0fh mov ar0, #.dl.lcddata and 0fh add ar0, pmn0 addc ar1, #0 addc ar2, #0 addc ar3, #0 movt dbf, @ar mov rph, #0 mov rpl, #0 skge pmn0, #0ah set1 ch bank2 ld lcdd0, dbf0 ld lcdd1, dbf1 ld lcdd2, dbf2 set1 lcden
pd17012, 17p012 229 data sheet u10101ej4v0ds figure 19-13. example of wiring lcd panel l c d 16 l c d 15 l c d 14 a g d f a l c d 13 l c d 12 a c b f b l c d 10 l c d 9 a g b f l c d 8 l c d 11 c d l c d 7 l c d 6 a g f l c d 5 d d l c d 4 l c d 3 l c d 2 l c d 1 a g c b f l c d 0 d ch l c d 17 l c d 18 am pm mhz khz l c d 19 c o m 0 c o m 1 c o m 2 segment pin common pin l c d 17 l c d 16 l c d 19 l c d 18 l c d 15 l c d 14 l c d 13 l c d 12 l c d 11 l c d 10 l c d 9 l c d 8 l c d 7 l c d 6 l c d 5 l c d 4 l c d 3 l c d 2 l c d 1 l c d 0 com 2 com 0 fm sw lw e a dc a e a d b c : e a d c c da d e c fpm khz am e a d ch c com 1 mw fgbfgbfgb g e fb g mhz f g b correspondence between segment and common pins and lcd panel display b e c e f g mw sw lw e c g e e c fm d b e
pd17012, 17p012 230 data sheet u10101ej4v0ds 19.8 status on reset 19.8.1 on power-on reset the lcd 19 /p2h 0 to lcd 0 /ks 0 /pya 0 pins are specified as lcd segment signal output pins, and output a low level. the com 2 to com 0 pins output a low level. therefore, the lcd display is turned off. 19.8.2 on execution of clock stop instruction the lcd 19 /p2h 0 to lcd 0 /ks 0 /pya 0 pins are specified as lcd segment signal output pins, and output a low level. the com 2 to com 0 pins output a low level. therefore, the lcd display is turned off. 19.8.3 on ce reset of the lcd 19 /p2h 0 to lcd 0 /ks 0 /pya 0 pins, those that are specified as segment signal output pins output segment signals, and those that are specified as general-purpose output port pins retain the current output value. the com 2 and com 0 pins output common signals. 19.8.4 in halt status of the lcd 19 /p2h 0 to lcd 0 /ks 0 /pya 0 pins, those that are specified as segment signal output pins output segment signals, and those that are specified as general-purpose output port pins retain the current output value. the com 2 and com 0 pins output common signals.
pd17012, 17p012 231 data sheet u10101ej4v0ds 20. key source controller/decoder the key source controller/decoder can configure a key matrix of up to 64 keys by outputting key source signals by means of the lcd segment signal output and time division. 20.1 configuration of key source controller/decoder figure 20-1 shows the configuration of the key source controller/decoder. as shown in the figure, the key source controller/decoder consists of a segment signal/general-purpose output port select block, segment signal/key source signal timing control block, key source data register, key input control block, and p0d port register. the following section 20.2 outlines the function of each block. figure 20-1. outline of key source controller/decoder dbf keyj flag p0d port register (data memory) from lcd segment register key source data register (ksr) segment signal/key source signal output timing control block segment signal/ general-purpose output port select block key input control block key matrix pyasel flag ......... lcden flag ksen flag lcd 15 /ks 15 /pya 15 lcd 14 /ks 14 /pya 14 lcd 2 /ks 2 /pya 2 lcd 1 /ks 1 /pya 1 lcd 0 /ks 0 /pya 0 p0d 3 /k 3 p0d 2 /k 2 p0d 1 /k 1 p0d 0 /k 0 ..... remarks 1. pyasel (bit 0 of the lcd mode select register; refer to 20.4.3 configuration and function of lcd mode select register ) sets the lcd 15 /ks 15 /pya 15 to lcd 0 /ks 0 /pya 0 pins in the lcd segment signal output or general-purpose output port mode. 2. lcden (bit 1 of the lcd mode select register; refer to 20.4.3 configuration and function of lcd mode select register ) turns on/off all lcd displays. 3. ksen (bit 1 of the lcd mode select register; refer to 20.4.3 configuration and function of lcd mode select register ) sets output of the key source signal. 4. keyj (bit 0 of the key input judge register; refer to 20.5.3 configuration and function of key input judge register ) detects whether the latch contents of the key input pin are valid.
pd17012, 17p012 232 data sheet u10101ej4v0ds 20.2 functional outline of key source controller/decoder the key source controller/decoder can configure a key matrix of up to 64 keys by using key source signal output pins (lcd 15 /ks 15 /pya 15 to lcd 0 /ks 0 /pya 0 ) and key input pins (p0d 3 /k 3 to p0d 0 /k 0 ). figure 20-2 shows the example of key matrix configuration. the lcd 15 /ks 15 /pya 15 to lcd 0 /ks 0 /pya 0 pins are multiplexed with lcd segment signal output pins. therefore, the key source signals and lcd segment signals are output by means of time-division multiplexing. the following subsections 20.2.1 through 20.2.3 outline the function of each block of the key source controller/ decoder. figure 20-2. example of key matrix configuration key source input pin key source output pin 20.2.1 key source data register (ksr) the key source data register sets the key source output data of the pin that outputs a key source signal. data is set to the key source data register via the data buffer. when data is set to this register, the key source data is output from the lcd 15 /ks 15 /pya 15 to lcd 0 /ks 0 /pya 0 pins. for details, refer to 20.3 . 20.2.2 segment signal/key source signal output timing control block the segment signal/key source signal output timing block controls the output timing of the key source and segment signals of the lcd 15 /ks 15 /pya 15 to lcd 0 /ks 0 /pya 0 pins. whether a key source signal is used or not is specified by the lcd mode select register. the key source signal is not output when lcd display is not used. in this case, the above pins output a low level. whether lcd display is not used or not is specified by the lcd mode select register. for details, refer to 20.4 . 20.2.3 key input control block and p0d port register the key input control block detects the key input signals input to the p0d 3 /k 3 to p0d 0 /k 0 pins in synchronization with key source signal output timing. to output the key source signals from the lcd 15 /ks 15 through lcd 0 /ks 0 pins, therefore, the p0d 3 /k 3 to p0d 0 / k 0 pins are used as key input pins. the key input data is read by the p0d port register (address 73h of bank0) in the data memory. for details, refer to 20.5 .
pd17012, 17p012 233 data sheet u10101ej4v0ds 20.3 key source data setting block 20.3.1 configuration of key source data setting block figure 20-3 shows the configuration of the key source data setting block. figure 20-3. configuration of key source data setting block data buffer (dbf) address symbol data 0ch dbf3 0dh dbf2 0eh dbf1 0fh dbf0 16 peripheral address 42h key source data register (ksr) key source data latch m s b l s b 20.3.2 function of key source data setting block the key source data setting block sets the key source data to be output from the lcd 15 /ks 15 /pya 15 to lcd 0 / ks 0 /pya 0 pins. the key source data is set to the key source data register (ksr: peripheral address 42h) via the data buffer. each bit of the key source data register corresponds to the lcd 15 /ks 15 /pya 15 to lcd 0 /ks 0 /pya 0 pins, and sets the key source data of each pin. when a bit of the key source data register is set to 1, the pin corresponding to this bit outputs a high level as a key source signal; when the bit is reset to 0, the corresponding pin outputs a low level. for the output timing, refer to 20.4 . the following subsections 20.3.3 explains the configuration and function of the key source data register. also refer to figure 19-5 in 19. lcd controller/driver .
pd17012, 17p012 234 data sheet u10101ej4v0ds 20.3.3 configuration and function of key source data register (ksr) the configuration and function of the key source data register are illustrated below. name symbol address bit data data buffer dbf3 0ch dbf2 0dh dbf1 0eh dbf0 0fh b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 transfer data 16 get can be executed put can be executed b 15 b 14 b 13 b 12 b 11 b 10 b 9 b 8 b 7 b 6 b 5 b 4 b 3 b 2 b 1 b 0 name peripheral register symbol ksr valid data peripheral address 42h peripheral hardware selects output pin of key source signal key source data register key source controller/decoder lcd 0 /ks 0 /pya 0 pin lcd 1 /ks 1 /pya 1 pin lcd 2 /ks 2 /pya 2 pin lcd 3 /ks 3 /pya 3 pin lcd 4 /ks 4 /pya 4 pin lcd 5 /ks 5 /pya 5 pin lcd 6 /ks 6 /pya 6 pin lcd 7 /ks 7 /pya 7 pin lcd 8 /ks 8 /pya 8 pin lcd 9 /ks 9 /pya 9 pin lcd 10 /ks 10 /pya 10 pin lcd 11 /ks 11 /pya 11 pin lcd 12 /ks 12 /pya 12 pin lcd 13 /ks 13 /pya 13 pin lcd 14 /ks 14 /pya 14 pin lcd 15 /ks 15 /pya 15 pin does not output key source signal outputs key source signal 0 1
pd17012, 17p012 235 data sheet u10101ej4v0ds 20.4 output timing control blocks and segment/port select block 20.4.1 configuration of output timing control blocks and segment/port select block figure 20-4 shows the configuration of the common signal and segment signal/key source signal output timing control blocks and segment signal/general-purpose output port select block. figure 20-4. configuration of timing control blocks and port select block key source data register/ port ya group register segment signal/ key source signal timing control lcdd15 | lcdd0 ksen flag lcden flag pyasel flag b 0 b 1 b 2 to key input control block and keyj flag segment signal/ key source signal port data basic clock for timing control 1 0 lcd 15 /ks 15 /pya 15 | lcd 0 /ks 0 /pya 0 20.4.2 function of output timing control block the segment signal/key source signal output timing control block controls the output timing of the key source and segment signals. the lcd segment signal is output when the lcden flag of the lcd mode select register is 1. all the lcd display dots can be turned off by resetting the lcden flag to 0. at this time, a low level is output as the segment signal, and the key source signal is not output. to output the key source signal, therefore, the lcden flag must be 1. the key source signal is also output when the ksen flag of the lcd mode select register is 1. therefore, the ksen flag is used to specify whether the key source signal is used or not. to output the key source signal, therefore, the lcden and ksen flags must be 1. the following subsection 20.4.3 indicates the configuration and function of the lcd mode select register. subsection 20.4.4 shows the output waveforms of the key source and segment signals. for the relationship between the common and segment signals of the lcd, and key source signal, refer to 19. lcd controller/driver .
pd17012, 17p012 236 data sheet u10101ej4v0ds 20.4.3 configuration and function of lcd mode select register the lcd mode select register turns on/off all the lcd display dots, and specifies output of the key source signal. the configuration and function of this register are illustrated below. 20.4.4 output waveforms of segment and key source signals figures 20-5 and 20-6 show the output waveforms of the key source and segment signals. as shown in figures, the key source and segment signals are output by means of time-division multiplexing. the key source signal is output for 220 s at intervals of 4 ms. to put it in another way, a pin corresponding to a bit of the key source data register that is set to 1 outputs a high level for 220 s every 4 ms, and a pin corresponding to a bit of the key source data register that is reset to 0 outputs a low level for 220 s every 4 ms. when output of the key source signal is selected (ksen flag = 1), pins that do not output key source signals (lcd 19 /p2h 0 to lcd 16 /p2e 0 ) output the waveform shown in figure 20-6. however, a waveform of 0 is output as the key source data. selects output of key source signal key source off key source on name flag symbol b 3 0 b 2 b 1 b 0 address 10h read/ write r/w 0 1 selects lcd segment output pin and general-purpose output port pins lcd 0 /ks 0 /pya 0 to lcd 15 /ks 15 /pya 15 used as lcd segment pins lcd 0 /ks 0 /pya 0 to lcd 15 /ks 15 /pya 15 used as general-purpose output port power-on clock stop ce 0 0 0 0 0 0 0 0 lcd mode select register fixed to 0 0 1 turns on/off all lcd display display off (all segment and common output pins output low level) display on 0 1 retained k s e n l c d e n p y a s e l after reset
pd17012, 17p012 237 data sheet u10101ej4v0ds figure 20-5. output waveforms of segment and key source signals (when ??is output as key source signal) dot a dot b dot c segment signal key source signal each segment/key source signal output pin (lcd n /ks n ) com 2 pin v dd 1/2 v dd gnd com 1 pin v dd 1/2 v dd gnd com 0 pin v dd 1/2 v dd gnd com 2 pin com 1 pin com 0 pin common signal each segment pin (pin outputting "1" as key source) <1> a = off, b = off, c = off <2> a = off, b = off, c = on <3> a = off, b = on, c = off <4> a = off, b = on, c = on <5> a = on, b = off, c = off <6> a = on, b = off, c = on <7> a = on, b = on, c = off <8> a = on, b = on, c = on 2 ms 2 ms 2 ms 2 ms 2 ms 2 ms 2 ms 2 ms 2 ms 2 ms 2 ms 2 ms 2 ms 220 s key source signal c = on c = on c = on c = on b = on c = on a = on a = on a = on a = on c = on b = on a = on a = on a = on a = on c = on c = on c = on b = on b = on b = on a = on a = on a = on a = on b = on b = on b = on b = on a = on a = on a = on a = on c = on c = on c = on c = on a = on a = on a = on a = on b = on c = on b = on c = on c = on b = on b = on b = on b = on b = on
pd17012, 17p012 238 data sheet u10101ej4v0ds figure 20-6. output waveforms of segment and key source signals (when 0 is output as key source signal) dot a dot b dot c segment signal key source signal each segment/key source signal output pin (lcd n /ks n ) com 2 pin v dd 1/2 v dd gnd com 1 pin v dd 1/2 v dd gnd com 0 pin v dd 1/2 v dd gnd com 2 pin com 1 pin com 0 pin common signal each segment pin (pin outputting "0" as key source) <1> a = off, b = off, c = off <2> a = off, b = off, c = on <3> a = off, b = on, c = off <4> a = off, b = on, c = on <5> a = on, b = off, c = off <6> a = on, b = off, c = on <7> a = on, b = on, c = off <8> a = on, b = on, c = on 2 ms 2 ms 2 ms 2 ms 2 ms 2 ms 2 ms 2 ms 2 ms 2 ms 2 ms 2 ms 2 ms 220 s key source signal c = on c = on c = on c = on b = on c = on a = on a = on a = on a = on c = on b = on a = on a = on a = on a = on c = on c = on c = on b = on b = on b = on a = on a = on a = on a = on b = on b = on b = on b = on a = on a = on a = on a = on c = on c = on c = on c = on a = on a = on a = on a = on b = on c = on b = on c = on c = on b = on b = on b = on b = on b = on
pd17012, 17p012 239 data sheet u10101ej4v0ds 20.5 key input control block 20.5.1 configuration of key input control block figure 20-7 shows the configuration of the key input control block. figure 20-7. configuration of key input control block input latch segment signal/key source signal output timing control block p0d port register half release signal keyj flag v dd high on resistance p0d 3 /k 3 p0d 0 /k 0 20.5.2 function of key input control block the key input control block controls the timing to read the key input signals from the p0d 3 /k 3 to p0d 0 /k 0 pins and reads the key input data. figure 20-8 illustrates the key input signals and key input timing. as shown in this figure, the internal-pull down resistors of the p0d 3 /k 3 to p0d 0 /k 0 pins are turned off while the display data of the lcd segment is output, and turned on only for 220 s while the key source signal is output. for the duration of 220 s during which the key source signal is output, the input signal of each key input pin is connected to the input latch. therefore, the signal input to each key input pin can be detected in the 220 s during which the key source signal is output. figure 20-9 shows the timing chart of the key source signal, key input signal, and key input data (p0d port register). whether a key source signal is output or not is detected by the keyj flag of the key input judge register (rf address 16h). the keyj flag is set after the key source signal has been output for 220 s, and is reset when data has been set to the key source data register and when the content of the keyj flag has been read. by detecting the keyj flag after the key source signal data has been output to the key source data register, and then detecting the status of each key input pin after the keyj flag has been set to 1, the key can be input. the following subsection 20.5.3 explains the configuration and function of the key input judge register.
pd17012, 17p012 240 data sheet u10101ej4v0ds figure 20-8. key source signal and key input timing each segment/key source signal output pin (lcd n /ks n ) dot b dot c com 1 pin dot a com 2 pin com 0 pin key source signal segment signal each segment pin (pin outputting "1" as key source, a = on, b = on, c = off) h l pull down open 1 0 segment pin key input pin keyj flag key source signal 220 s 2 ms put ksr, dbf or skt 1 keyj input data is latched at this point. signal input to p0d 3 /k 3 to p0d 0 /k 0 pins is connected to input latch during this period. if put ksr, dbf is executed during this period, keyj flag is not set for 4 ms. put ksr, dbf or skt1 keyj 2 ms caution the keyj flag is not set to 1 when in halt mode.
pd17012, 17p012 241 data sheet u10101ej4v0ds figure 20-9. timing chart of key source signal, key input signal, and key input data (p0d port register) h l input data is latched at this point. h l 1 0 h l 1 0 the keyj flag is ??during this period. if the value of p0d is read, the status of the p0d pin is read. segment pin <1> when p0d port register is ? key input pin input signal <2> when p0d port register is ? p0d port register key input pin input signal p0d port register 20.5.3 configuration and function of key input judge register the key input judge register detects the presence or absence of the key input signal latch when the lcd segment signal output pins are shared with key source signal output. the configuration and functions of this register are illustrated below. name flag symbol b 3 0 b 2 0 b 1 0 b 0 address 16h read/ write 0 1 detects valid/invalid latch contents of key input signal invalid key latch contents valid latch contents after reset power-on clock stop ce 0000 0 0 key input judge register fixed to 0 k e y j r & reset caution the keyj flag is not set to 1 when in halt mode. the keyj flag retains the data prior to halt instruction execution.
pd17012, 17p012 242 data sheet u10101ej4v0ds 20.6 using key source controller/decoder 20.6.1 configuring key matrix figure 20-10 shows an example of configuring a key matrix. as shown in this figure, the key matrix can be configured for up to 64 keys. because the key source signal output pins also output the lcd segment signals at the same time, diode a must be used to prevent the reverse flow of the lcd segment signal if a momentary switch is used. diodes b and c are used to prevent sneaking of the key source signal. use a pnp transistor as the transistor switch. the following (1) explains the points to be noted when an npn transistor is used. (2) through (4) explain the points to be noted if diodes a, b, and c are not used. figure 20-10. example of key matrix configuration 76 75 74 73 67 66 65 63 62 61 60 59 58 52 50 to lcd panel configuration of each switch ks a b k momentary switch ks k ks k alternate switch ks k c or ks k c ks k diode switch ks k (80 pin) 62 61 60 59 57 56 55 53 52 51 50 49 48 43 42 (64 pin) 64 54
pd17012, 17p012 243 data sheet u10101ej4v0ds (1) notes on using npn transistor switch when an npn transistor switch is used, the low level may not be accurately read as illustrated in the figure below. if ks is low and a high level is input to the base of the transistor in the figure on the left, voltage v k input to k is as follows. r b v k = (v dd v be ) r a + r b a low level must be input to k at this time because ks is low. however, the voltage input to k changes depending on r a and r b , as indicated by the above expression. therefore, a low level may not be input depending on the values of r a and r b . (2) notes when diode a is not used an example of a circuit where diode a is missing is shown below. suppose switches sw1 and sw2 are on, ks 15 outputs a high level, and ks 14 outputs a low level, as shown below. if diode a is missing, currents i 1 and i 2 indicated by the dotted lines flow. consequently, the high level of ks 15 and low level of ks 14 are not output correctly because of i 2 , and the key input data of k 3 cannot be accurately read. if ks 15 and ks 14 are used to output lcd segment signals, the lcd cannot be turned on/off correctly. k 2 k 3 ks 14 ks 15 lcd lcd sw1 sw2 i 1 i 2 low high ks internal resistor r b k r a v dd high low
pd17012, 17p012 244 data sheet u10101ej4v0ds (3) notes when diode b is not used an example of a circuit where diode b is not used is shown below. suppose switches sw1, sw2, and sw4 are on, and ks 7 outputs a high level, as shown below. if diode b is missing, currents i 1 and i 2 flow as indicated by the dotted lines. consequently, a high level is input to k 2 because of i 2 despite that switch sw3 is off, and it is judged that sw3 is on. k 2 k 3 ks 7 ks 8 sw2 sw4 i 1 high low sw3 sw1 i 2 (4) note when diode c is not used an example of a circuit where diode c is not used is shown below. suppose switches sw2, sw3, and sw4 are on, and ks 8 outputs a high level, as shown below. if diode c is missing, currents i 1 , i 2 , and i 3 flow as indicated by the dotted lines. consequently, a high level is input to k 2 because of i 2 despite the fact that switch sw1 is off, and it is judged that sw1 is on. moreover, ks 8 cannot output a high level correctly because of i 3 . k 2 k 3 ks 7 ks 8 sw2 sw4 i 1 low sw3 sw1 i 2 i 3 high
pd17012, 17p012 245 data sheet u10101ej4v0ds 20.6.2 reading alternate switches and diode switches here is a program example. example to read statuses of alternate and diode switches of lcd 15 /ks 15 /pya 15 to lcd 8 /ks 8 /pya 8 pins to addresses 20h to 27h of bank0 of data memory ks8 nibble8 0.20h key_in mem 0.73h ; p0d port register key_load: clr1 pyasel ; sets lcd 15 /ks 15 /pya 15 to lcd 8 /ks 8 /pya 8 pins ; to lcd segment set2 lcden, ksen ; lcd segment and key source signal output mov dbf3, #0000b ; sets key source data mov dbf2, #0001b ; outputs low level from ks 8 mov dbf1, #0000b mov dbf0, #0000b mov ixm, #0000b mov ixl, #0000b mov rph, #0000b mov rpl, #0000b kscan: put ksr, dbf ; outputs signal of key source data loop: skf1 keyj ; determines if key input is latched br kcheck processing a ; waits until key input is latched br loop kcheck: mov rpl#.dm.key_in shr 3 and 0eh set1 ixe st ks8, key_in ; stores key input data to data memory clr1 ixe mov rpl, #0000b inc ix add dbf2, dbf2 ; updates value of key source data and add dbf3, dbf3 ; scans key again skt1 cy ; determines if all key source lines are input br kscan key_end: ; end of input
pd17012, 17p012 246 data sheet u10101ej4v0ds 20.6.3 inputting momentary switch by binary search the key source controller/decoder requires 4 ms to input the key of one key source signal line. to input the keys of 16 key source signals, therefore, it takes 64 ms. it is therefore convenient if the binary search method explained in (1) and (2) below is used. (1) flowchart when ks 7 to ks 0 are used as key source signals of momentary switch start ; sets key source controller end ; sets offset address of table storing key source data to ra ar ksdata+ra dbf @ ar ksr dbf keyj = 1? n y ; waits until data is latched to key input latch (4 ms) ; outputs key source data at offset address specified by ra ; saves key input data to rb initialization ra 0000b rb p0d port register ra = rb = 0? y n ; if key input data and ra are "0", inputs all keys again because no ; key is input ; if ra is less than "7", updates ra and continues binary search ra ra+ra rb = 0? n y ra > 7? y n ; if ra is greater than "7", input of one key source ends and waits for ; chattering ra ra+1 rb = 0? y n ; if there is no key input data, checks all keys again ; even if this chattering wait is missing, chattering occurs for 4 ms chattering wait ; inputs key input determined by binary search to rc again dbf ksr ksr dbf keyj = 1? n y ; if rc = 0, occurrence of chattering is determined, and keys are input ; from beginning rc p0d port register rc = 0? y n ; stores key input data before chattering to rb, data after chattering ; to rc, and key source data to ra checking of key data
pd17012, 17p012 247 data sheet u10101ej4v0ds example of table data for binary search table data (key source data) b 15 b 14 b 13 b 12 b 11 b 10 b 9 b 8 b 7 b 6 b 5 b 4 b 3 b 2 b 1 b 0 0000b 0001b 0010b 0011b 0100b 0101b 0110b 0111b 1000b 1001b 1010b 1011b 1100b 1101b 1110b 1111b (2) program example ra mem 0.1ah ; general-purpose work register rb mem 0.1bh ; general-purpose work register rc mem 0.1ch ; general-purpose work register key_in mem 0.73h ; p0d port register ksdata: ; kkkkkkkkkkkkkkkk ; ssssssssssssssss ; 1111119876543210 ; 543210 dw 0000000011111111b ; ra = 0 dw 0000000011110000b ; ra = 1 dw 0000000000001100b ; ra = 2 dw 0000000000110000b ; ra = 3 dw 0000000000000010b ; ra = 4 dw 0000000000001000b ; ra = 5 dw 0000000000100000b ; ra = 6 dw 0000000010000000b ; ra = 7 dw 0000000000000001b ; ra = 8 dw 0000000000000010b ; ra = 9 dw 0000000000000100b ; ra = 10 dw 0000000000001000b ; ra = 11 dw 0000000000010000b ; ra = 12 dw 0000000000100000b ; ra = 13 dw 0000000001000000b ; ra = 14 dw 0000000010000000b ; ra = 15 key_load: clr1 pyasel ; sets lcd 15 /ks 15 /pya 15 to lcd 8 /ks 8 /pya 8 pins ; to lcd segment set2 lcden, ksen ; lcd segment and key source signal output
pd17012, 17p012 248 data sheet u10101ej4v0ds start: mov ra, #0000b kscan: mov ar3, #.dl.ksdata shr 0ch and 0fh mov ar2, #.dl.ksdata shr 8 and 0fh mov ar1, #.dl.ksdata shr 4 and 0fh mov ar0, #.dl.ksdata and 0fh mov rpl, #.dl.ar0 shr 3 and 0eh add ar0, ra addc ar1, #0 addc ar2, #0 addc ar3, #0 mov rpl, #0 movt dbf, @ar ; reads table data put ksr, dbf ; outputs signal of key source data loop1: skf1 keyj ; determines if key input is latched br kcheck processing a ; waits until key input is latched br loop1 kcheck: mov prl, #.dm.rb shr 3 and 0eh ld rb, key_in ; stores key input data to rb skne ra, #0000b ; all keys are checked? ske rb, #0000b br key input br start ; there is no key input key input: sklt ra, #1000b ; key sources are narrowed down to one? br lastchk ; if not, updates value of ra, and scans keys again add ra, ra ske rb, #0000b add ra, #0001b br kscan lastchk: mov rpl, #0 skne rb, #0000b ; key input to one key source? br start ; if not, it is determined that chattering occurs chattering wait
pd17012, 17p012 249 data sheet u10101ej4v0ds loop2: skf1 keyj ; determines if key input is latched br keydec processing b ; waits until key input is latched br loop2 keydec: mov rpl, #.dm.rc shr 3 and 0eh ld rc, key_in ; stores key input data to latch set2 cap, z ; compares key input data after chattering with key input sub rc, rb ; data before chattering wait skt1 z br start ; if data differ key_end: ; stores key source data to ra, key input data before ; chattering to rb, and key input data after chattering to rc
pd17012, 17p012 250 data sheet u10101ej4v0ds 20.7 status on reset 20.7.1 on power-on reset the lcd 19 /p2h 0 to lcd 0 /ks 0 /pya 0 pins are specified as the lcd segment signal output pins and output a low level (display off). a low level is output as the key source signal. 20.7.2 on execution of clock stop instruction the lcd 19 /p2h 0 to lcd 0 /ks 0 /pya 0 pins are specified as the lcd segment signal output pins and output a low level (display off). a low level is output as the key source signal. 20.7.3 on ce reset the output data is retained as is if the key source signal is being output. 20.7.4 in halt status the output data is retained as is if the key source signal is being output. if key input is specified as a halt status releasing condition, the halt status is released when a high level is input to the p0d 3 /k 3 to p0d 0 /k 0 pins. if the key source controller is used, however, the halt status is released only by a high level that is input within 220 s during which the key source data is output. for an explanation of how to release the halt status by key input, refer to 21.4 halt function . figure 20-11. keyj flag status in halt status halt status keyj flag is not set in halt status keyj flag is set at this point halt released status halt is released by inputting int or tmcy (timer carry) h key input pin keyj flag l 1 0
pd17012, 17p012 251 data sheet u10101ej4v0ds 21. standby the standby function is used to reduce the current consumption of the device during back up. 21.1 configuration of standby block figure 21-1 shows the configuration of the standby block. as shown in the figure, the standby block is divided into two blocks: halt control block and clock stop control block. the halt control block consists of a halt controller, interrupt control block, timer carry, and key input pins p0d 0 /k 0 to p0d 3 /k 3 , and controls the operation of the cpu (program counter, instruction decoder, and alu block). the clock stop control block controls the 4.5 mhz crystal oscillator, cpu, system register, and control registers, by using the clock stop controller. figure 21-1. configuration of standby block interrupt block basic timer 0 halt controller halt h program counter (pc) instruction decoder alu system register control register clock stop controller stop s halt block clock stop block p0d 3 /k 3 pin p0d 2 /k 2 pin p0d 1 /k 1 pin p0d 0 /k 0 pin ce pin x out pin x in pin internal block cpu ce flag input latch remark ce (bit 0 of the ce pin level judge register; refer to 21.3.5 configuration and function of ce pin level judge register ) detects the ce pin status.
pd17012, 17p012 252 data sheet u10101ej4v0ds 21.2 standby function the standby function reduces the current consumption of the device by stopping some or all its operations. the standby function can be used in two modes: halt and clock stop. the halt mode is to reduce the current consumption of the device by executing a dedicated instruction ?alt h?and stopping the operation of the cpu. the clock stop mode is to reduce the current consumption of the device by executing a dedicated instruction ?top s?and stopping the 4.5 mhz crystal oscillator. in addition to the halt and clock stop modes, the operation mode of the device can be also set by the ce pin. the ce pin is used to control the operation of the pll frequency synthesizer and reset the device, and can be said to be a type of the standby function in that it controls the operation of the pll frequency synthesizer. the following section 21.3 explains how to set the operation mode of the device by using the ce pin. sections 21.4 and 21.5 explain the halt and clock stop modes respectively. 21.3 selecting device operation mode with ce pin the ce pin controls the following functions (1) through (3) by using the level and rising edge of an externally input signal. (1) controls operation of pll frequency synthesizer (2) enables or disables clock stop instruction (3) resets device 21.3.1 controlling operation of pll frequency synthesizer the pll frequency synthesizer can operate only when the ce pin is high. the pll frequency synthesizer is automatically disabled when the ce pin is low. at this time, the vcoh and vcol pins are internally pulled down, and the eo pin is floated. the pll frequency synthesizer can be disabled by the pll reference clock select register at any time when the ce pin is high. 21.3.2 enabling and disabling clock stop instruction the clock stop instruction ?top s?is enabled only when the ce pin is low. the stop s instruction is executed as a no-operation (nop) instruction if it is executed when the ce pin is high. 21.3.3 resetting device the device can be reset (ce reset) by raising the ce pin. the device can also be reset through power application (power-on reset). for details, refer to 22. reset .
pd17012, 17p012 253 data sheet u10101ej4v0ds 21.3.4 inputting signal to ce pin the ce pin does not accept a low or high level of less than 110 to 165 s to prevent malfunctioning due to noise. the level of the signal input to the ce pin can be detected by using the ce flag of the ce pin level judge register (rf address 07h). figure 21-2 shows the relationship between the input signal and ce flag. figure 21-2. relationship between signal input to ce pin and ce flag h l 1 0 ce pin ce flag ce reset less than 110 to 165 s 110 to 165 s 110 to 165 s pll operation enabled stop s instruction disabled (nop) pll disabled stop s instruction enabled pll disabled stop s instruction enabled (nop) ce reset is executed in synchronization with next setting of timer carry ff ? less than 110 to 165 s 21.3.5 configuration and function of ce pin level judge register the ce pin level judge register detects the level of the signal input to the ce pin. the configuration and function of this register are illustrated below. name flag symbol b 3 0 b 2 0 b 1 0 b 0 c e address 07h read/ write r 0 1 detects level input to ce pin low level high level power-on clock stop ce reset 000 ce pin level judge register fixed to 0 : determined depending on pin status after reset the ce flag is not affected by a low or high level of less than 110 to 165 s.
pd17012, 17p012 254 data sheet u10101ej4v0ds 21.4 halt function the halt function stops the operation clock of the cpu by executing the halt h instruction. when the halt h instruction is executed, the program stops at the halt h instruction, until the halt status is released later. therefore, the current consumption of the device can be reduced in the halt status by the operating current of the cpu. the halt status can be released by key input, timer carry, or interrupt. the releasing condition of the key input, timer carry, and interrupt is specified by the operand h of the halt h instruction. the halt h instruction is valid regardless of the input level of the ce pin. the following subsections 21.4.1 through 21.4.6 explain the halt status, halt release condition, and each halt release condition. 21.4.1 halt status all the operations of the cpu are stopped in the halt status. in other words, program execution is stopped at the halt h instruction. however, the peripheral hardware units continue the operations set before the halt h instruction is executed. for the operations of the peripheral hardware units, refer to 21.6 device operations in halt and clock stop status .
pd17012, 17p012 255 data sheet u10101ej4v0ds 21.4.2 halt release condition figure 21-3 shows the halt release conditions. as shown in this figure, the halt release conditions are set by 4-bit data specified by operand h of the halt h instruction. the halt status is released when the condition specified as 1 by operand h is satisfied. when the halt status is released, the execution starts from the instruction next to the halt h instruction. if two or more release conditions are specified, and if any one of the specified conditions is satisfied, the halt condition is released. if the device is reset (power-on reset or ce reset), the halt status is released, and each reset operation is performed. if 0000b is set as the halt release condition h , no release condition is set. at this time, the halt status is released if the device is reset (power-on reset or ce reset). the following subsections 21.4.3 through 21.4.5 explains halt release conditions set by key input, basic timer 0, and interrupt. 21.4.6 shows an example when two or more release conditions are specified. figure 21-3. halt release condition operand bit b 3 b 2 b 1 b 0 sets halt release condition halt h (4 bits) releases if high level is input to p0d pin (p0d 3 /k 3 to p0d 0 /k 0 ) releases if basic timer 0 carry ff is set to 1 undefined (fixed to 0) releases if interrupt (int pin or timer) is acknowledged does not release even if condition is satisfied releases if condition is satisfied 0 1
pd17012, 17p012 256 data sheet u10101ej4v0ds 21.4.3 releasing halt status by key input releasing the halt status by key input is specified by the halt 0001b instruction. if releasing the halt status by key input is specified, the halt status is released when a high level is input to any of the four pins p0d 0 /k 0 to p0d 3 /k 3 . the following paragraphs (1) through (3) explain the points to be noted when using a general-purpose output port for a key source signal and when multiplexing lcd segment signal outputs with key source signal outputs. (1) notes on using general-purpose output port for key source signal latch p0d 3 /k 3 p0d 2 /k 2 p0d 1 /k 1 p0d 0 /k 0 general-purpose output port switch a the halt 0001b instruction is executed after a general-purpose output port for key source signal goes high. if an alternate switch such as switch a in the above figure is used at this time, a high level is always applied to the p0d 0 /k 0 pin while switch a is closed, and the halt status is immediately released. therefore, care must be exercised in using the alternate switch. when using a general-purpose output port for key source signal, reset the ksen flag of the lcd mode select register (rf address 10h) to 0. at this time, the p0d 0 /k 0 to p0d 3 /k 3 pins are automatically pulled down.
pd17012, 17p012 257 data sheet u10101ej4v0ds (2) notes on multiplexing lcd segment signal and key source signal outputs latch p0d 3 /k 3 p0d 2 /k 2 p0d 1 /k 1 p0d 0 /k 0 lcd 15 /ks 15 /pya 15 lcd segment signal 220 s key source signal l h lcd segment signal output waveform execute the halt 0001b instruction after setting key source signal output data. at this time, the halt status is not released even if a high level of the lcd segment signal is input to the pin whose key source signal output data is 0 . to multiplex an lcd segment signal output with a key source signal output, set the ksen flag of the lcd mode select register to 1. the key source signal data (setting the pin that outputs a key source) is set by the key source data register (ksr: peripheral address 42h) via the data buffer. the internal key latch circuit when an lcd segment signal output is multiplexed with a key source signal output latches data only while the key source signal is output, and is disconnected from the external source while the lcd segment signal is output. the internal pull-down resistor is on only when the key source signal is output. (3) when releasing from halt status using other microcontrollers latch p0d 3 /k 3 p0d 2 /k 2 p0d 1 /k 1 p0d 0 /k 0 general-purpose output port or lcd segment signal output output port microcontroller, etc. the p0d 0 /k 0 to p0d 3 /k 3 pins can also be used as general-purpose input port pins with pull-down resistors. therefore, the halt status can also be released by using other microcontrollers as shown above.
pd17012, 17p012 258 data sheet u10101ej4v0ds 21.4.4 releasing halt status by basic timer 0 releasing the halt status by basic timer 0 is set by the halt 0010b instruction. when the release of the halt status is set by basic timer 0, the halt status is released as soon as the basic timer 0 carry ff has been set to 1. the basic timer 0 carry ff corresponds to the btm0cy flag of the basic timer 0 carry ff judge register on a one-to-one basis, as explained in 12. timer , and is set to 1 at fixed time intervals (1 ms, 5 ms, 100 ms, or 250 ms). therefore, the halt status can be released at fixed time intervals. example m1 mem 0.10h ; 1-second counter hlttmr dat 0010b ; symbol definition initflg not btm0ck1, btm0ck0 ; embedded macro ; sets basic timer 0 carry ff setting time to 250 ms loop: halt hlttmr ; sets release condition by basic timer 0 carry ff and halt status skt1 btm0cy ; embedded macro br loop ; branches to loop if btm0cy flag is not set add m1, #0100b ; adds 0100b to contents of m1 skt1 cy ; embedded macro br loop ; executes processing a if carry occurs processing a br loop in this example, the halt status is released every 250 ms and processing a is executed every 1 second. 21.4.5 releasing halt status by interrupt releasing the halt status by an interrupt is set by the halt 1000b instruction. if releasing the halt status by an interrupt is set, the halt status is released as soon as the interrupt has been acknowledged. four interrupt sources are available as explained in 11. interrupts . therefore, the interrupt source to be used to release the halt status must be specified by program in advance. so that the interrupt is acknowledged, all the interrupts must be enabled (by the ei instruction), each interrupt is enabled (by setting the corresponding interrupt enable flag), in addition that the interrupt request must be issued from each interrupt source. even if an interrupt request is issued, if that interrupt is not enabled, the interrupt is not acknowledged and the halt status is not released. when the halt status has been released because the interrupt has been acknowledged, the program flow branches to the vector address of the interrupt. if the reti instruction is executed after the interrupt processing, the program flow returns to the instruction next to the halt instruction. here is an example.
pd17012, 17p012 259 data sheet u10101ej4v0ds example hltint dat 1000b ; symbol definition of halt condition inttm dat 0003h ; interrupt vector address symbol definition intpin dat 0004h ; interrupt vector address symbol definition start: ; program address 0000h br main org inttm ; 12-bit timer interrupt vector address (0003h) br inttimer org intpin ; int pin interrupt vector address (0004h) processing a ; interrupt processing by int pin br ei_reti inttimer: processing b ; interrupt processing by 12-bit timer ei_reti: ei reti main: set2 iptm, ip0 ; embedded macro set2 btm1ck1, btm1ck0 ; embedded macro ; sets time interval of 12-bit timer to 1 ms loop: processing c ; main routine processing ei ; enables all interrupts halt hltint ; specifies releasing halt by interrupt ; <1> br loop in this example, the halt status is released when the 12-bit timer interrupt is acknowledged, and processing b is executed. when the int pin interrupt is acknowledged, processing a is executed. each time the halt status is released, processing c is executed. if the int pin interrupt request and 12-bit timer interrupt request are issued at the same time in the halt status, processing a of the int pin, which has the higher hardware priority, is executed. if reti is executed after execution of processing a, execution restores to the br loop instruction in <1>, but the br loop instruction is not executed, and the 12-bit timer interrupt is immediately acknowledged. if reti is executed after processing b of the 12-bit timer interrupt has been executed, the br loop instruction is executed.
pd17012, 17p012 260 data sheet u10101ej4v0ds caution when executing the halt instruction that will set the release condition where by the halt status is released by the setting of the interrupt request flag (irq ) when the interrupt enable flag (ip ) is set, describe a nop instruction immediately before the halt instruction. if a nop instruction is described immediately before the halt instruction, a time of one instruction is generated in between the irq manipulation instruction and halt instruction. in the case of the clr1 irq instruction, for example, clearing irq is correctly reflected on the halt instruction (refer to example 1 below). if a nop instruction is not described immediately before the halt instruction, the clr1 irq instruction is not correctly reflected on the halt instruction, and the halt mode is not set (refer to example 2 below). example 1. program that correctly executes halt instruction ; sets irq clr1 irq nop ; describes nop instruction immediately before ; halt instruction ; (clearing irq is correctly reflected on halt ; instruction) halt 1000b ; correctly executes halt instruction ; (halt mode is set) 2. program that does not set halt mode ; sets iqr clr1 irq ; clearing irq is not reflected on halt instruction ; (but on instruction next to halt) halt 1000b ; halt instruction is ignored (halt mode is not set)
pd17012, 17p012 261 data sheet u10101ej4v0ds 21.4.6 if two or more release conditions are simultaneously set if two or more release conditions are simultaneously set, and if even one of the conditions is satisfied, the halt status is released. the method to identify the release condition that is satisfied when two or more release conditions are specified is shown below. example hltint dat 1000b hlttmr dat 0010b hltkey dat 0001b intpin dat 0004h ; int pin interrupt vector address symbol ; definition start: br main org intpin processing a ; int pin interrupt processing ei reti tmrup ; basic timer 0 processing processing b ret keydec: ; key input processing processing c ret main: movt dbf, @ar ; sets key source output data (table reference) ; to key source data register (ksr) put ksr, dbf set2 ksen, lcden ; embedded macro ; multiplexes lcd segment signal output with ; key source signal output set2 btm0ck1, btm0ck0 ; embedded macro ; sets basic timer 0 carry ff setting time to 1 ms set1 ip ; embedded macro ; enables int pin interrupt ei loop: halt hltint or hlttmr or hltkey ; specifies interrupt, basic timer 0, and key input ; as halt release conditions skf1 btm0cy ; embedded macro ; detects btm0cy flag call tmrup ; basic timer 0 processing if set to 1 skf1 keyj ; embedded macro ; detects key input latch note call keydec ; key input processing if latched br loop note if the target key source output data is not output, the keyj flag is not set (1).
pd17012, 17p012 262 data sheet u10101ej4v0ds 21.5 clock stop function the clock stop function stops the 4.5 mhz crystal oscillator by executing the stop s instruction (clock stop status). therefore, the current consumption of the device is decreased to the minimum value of 10 a. specify 0000b as operand s of the stop s instruction. the stop s instruction is valid only while the ce pin is low. it is executed as a no-operation (nop) instruction even when executed while the ce pin is high. in other words, the stop s instruction must be executed while the ce pin is low. the clock stop status is released by raising the level of the ce pin from low to high (ce reset). the following subsections 21.5.1 through 21.5.3 explain the clock stop status, how to release the clock stop status, and notes on using the clock stop instruction. 21.5.1 clock stop status because the crystal oscillator is stopped in the clock stop status, all the device operations, such as those of the cpu and peripheral hardware, are stopped. for the operations of the cpu and peripheral hardware, refer to 21.6 device operations in halt and clock stop status . the power failure detector does not operate in the clock stop status even if the supply voltage v dd of the device is lowered to 2.3 v. therefore, the data memory can be backed up at a low voltage. for details of the power failure detector, refer to 22. reset . 21.5.2 releasing clock stop status the clock stop status is released either by raising the level of the ce pin from low to high (ce reset), or by lowering the supply voltage v dd of the device to 2.3 v or less once, and then increasing it to 3.5 v (power-on reset). figures 21-4 and 21-5 show how the clock stop is released on ce reset and power-on reset respectively. if the clock stop status is released by power-on reset, the power failure detector operates. for details of power-on reset, refer to 22.4 power-on reset .
pd17012, 17p012 263 data sheet u10101ej4v0ds figure 21-4. releasing clock stop status by ce reset 5 v 0 v h l h l v dd ce pin x out pin stop s instruction program starts from address 0 (ce reset) operation is as follows if clock stop instruction is not used 5 v 0 v h l h l v dd ce pin x out pin 0 - t set program starts from address 0 (ce reset) ce reset is effected in synchronization with setting of basic timer 0 carry ff after ce pin has gone high about 50 ms figure 21-5. releasing clock stop status by power-on reset 5 v 0 v h l h l v dd ce pin x out pin operation is as follows if clock stop instruction is not used 5 v 0 v h l h l v dd ce pin x out pin stop s instruction about 50 ms program starts from address 0 (power-on reset) 2.3 v 3.5 v oscillation stops about 50 ms program starts from address 0 (power-on reset)
pd17012, 17p012 264 data sheet u10101ej4v0ds 21.5.3 notes on using clock stop instruction the clock stop (stop s) instruction is valid only while the ce pin is low. therefore, processing to be performed if the ce pin happens to be high must be taken into consideration. take the following program as an example. example xtal dat 0000b ; symbol definition of clock stop condition cejdg: ; <1> skf1 ce ; embedded macro ; detects input level of ce pin br main ; branches to main processing if ce = high processing a ; processing of ce = low ; <2> stop xtal ; clock stop ; <3> br $ ?1 main: main processing br cejdg in the above example, the status of the ce pin is detected in <1>. if the ce pin is low, processing a is performed and then the clock stop instruction stop xtal in <2> is executed. if the ce pin goes high while the stop xtal instruction in <2> is executed, however, the stop xtal instruction is treated as a no-operation (nop) instruction. should branch instruction br$ 1 in <3> be missing at this time, the program would execute the main processing, causing malfunctioning. therefore, either a branch instruction must be inserted as in <3>, or the program must be designed in the manner that malfunctioning does not occur even if the main processing is executed. if a branch instruction is used as in <3>, ce reset is executed in synchronization with the next setting of the timer carry ff even while the ce pin is high. 5 v 0 v h l v dd ce pin program starts from address 0 in synchronization with setting of basic timer 0 carry ff (ce reset). main processing processing a <1> <1> <1> <2> stop xtal is treated as nop instruction because ce pin is high. detection of ce pin
pd17012, 17p012 265 data sheet u10101ej4v0ds 21.6 device operations in halt and clock stop status table 21-1 shows the operations of the cpu and peripheral hardware in the halt status and clock stop status. as shown in this table, all the peripheral hardware units continue the normal operation in the halt status, except that instruction execution is stopped. all the peripheral hardware units stop operation in the clock stop status. the control registers that control the operations of the peripheral hardware units operate normally in the halt status (i.e., are not initialized), but are initialized to specific values in the clock stop status (as soon as the stop s instruction has been executed). to put in another way, the peripheral hardware units continue the operations set by the control registers in the halt status, and operate in accordance with the control registers that are initialized to specific values in the clock stop status. for the values to which the control registers are initialized, refer to 8. register file (rf) . the following shows an example. example when the p0a 0 /si 1 pin of port 0a is specified as an output port pin, and the p0a 1 /so 1 and p0a 2 /sck 1 pins are used for the serial interface hltint dat 1000b xtal dat 0000b initflg p0abi02, p0abi01, p0abi00 ; <1> set3 p0a2, p0a1, p0a0 ; <2> initflg si01hiz, si01ck1, si01ck0 clr1 irqsi01 set1 ipsi01 ei ; <3> set1 si01ts ; <4> halt hltint ; <5> stop xtal in the above example, the p0a 2 through p0a 0 pins output a high level in <1>, the condition of serial interface 1 is set in <2>, and serial communication is started in <3>. when the halt instruction is executed in <4>, serial communication continues and the halt status is released when the interrupt by serial interface 1 is acknowledged. if the stop instruction in <5> is executed instead of the halt instruction in <4>, the contents of all the control registers set in <1>, <2>, and <3> are initialized. consequently, serial communication is stopped, and all the pins of port 0a are set in the general-purpose input port mode.
pd17012, 17p012 266 data sheet u10101ej4v0ds table 21-1. device operations in halt status and clock stop status peripheral hardware status ce pin = high ce pin = low halt clock stop halt clock stop program counter stops at address of stop instruction is stops at address of initialized to 0000h halt instruction invalid (nop) halt instruction and stops system register retained retained initialized note peripheral register retained retained retained control register retained retained initialized note timer normal operation normal operation stops operation pll frequency synthesizer normal operation disabled disabled a/d converter normal operation normal operation stops operation d/a converter normal operation normal operation stops operation beep output normal operation normal operation stops operation serial interface normal operation normal operation stops operation frequency counter normal operation normal operation stops operation lcd controller/driver normal operation normal operation stops operation key source controller/ normal operation normal operation stops operation decoder general-purpose i/o port normal operation normal operation input port general-purpose input port normal operation normal operation input port general-purpose output normal operation normal operation retained port note for the values to which these registers are initialized, refer to 5. system register (sysreg) and 8. register file (rf) . 21.7 notes on processing each pin in halt and clock stop status the halt status is used to reduce the current consumption, when only the watch operates, for example. the clock stop function is used to reduce the current consumption when only the contents of the data memory are to be retained. therefore, the current consumption must be reduced as much as possible in the halt and clock stop statuses. at this time, the current consumption may increase depending on the status of each pin, and therefore the points shown in table 21-2 must be noted.
pd17012, 17p012 267 data sheet u10101ej4v0ds table 21-2. notes on status of each pin in halt and clock stop statuses (1/2) pin function pin symbol status of each pin and notes on processing halt clock stop general- port 0a p0a 2 /sck 1 purpose p0a 1 /so 1 i/o port p0a 0 /si 1 port 0b p0b 3 /fcg 1 p0b 2 /fcg 0 p0b 1 /beep 1 p0b 0 /beep 0 port 1a p1a 2 p1a 1 p1a 0 port 1d p1d 3 p1d 2 p1d 1 p1d 0 general- port 0d p0d 3 /k 3 purpose p0d 2 /k 2 input port p0d 1 /k 1 p0d 0 /k 0 port 1b p1b 3 /fmifc p1b 2 /amifc p1b 1 /adc 1 p1b 0 /adc 0 general- port 0c p0c 3 purpose p0c 2 output port p0c 1 /pwm 1 p0c 0 /pmw 0 port 1c p1c 3 p1c 2 p1c 1 p1c 0 interrupt int current consumption increase due to external noise if this pin is floated. previous status before halt status is set is retained as is. (1) in output mode current consumption increases if these pins are externally pulled down while they output high level, or externally pulled up while they output low level. pay attention to n-ch open-drain output pins (p0c 3 to p0c 0 / pwm 0 ). (2) in input mode (except p0b 3 /fcg 1 , p0b 2 /fcg 0 , p1b 3 /fmifc, p1b 2 /amifc) current consumption increases due to noise if these pins are floated. (3) port 0d (p0d 3 /k 3 to p0d 0 /k 0 ) current consumption increases if these pins are externally pulled up because they have pull-down resistors. (4) p0b 3 /fcg 1 , p0b 2 /fcg 0 , p1b 3 / fmifc, p1b 2 /amifc current consumption increases when p0b 3 /fcg 1 , p0b 2 /fcg 0 , p1b 3 /fmifc, p1b 2 /amifc pins are used for if counter because internal amplifier operates. because if counter is not automatically disabled even if ce pin goes low, it must be initialized by program as necessary. p0b 3 /fcg 1 , p0b 2 /fcg 0 , p1b 3 / fmifc, p1b 2 /amifc are designed to prevent increase in current consumption due to noise even if they are set in general purpose input port mode and floated. all these pins are set in general-purpose input port mode. all input ports, except port 1d (p1d 3 to p1d 0 ), are designed to prevent increase in current consumption due to noise even if they are externally floated. port 1d (p1d 3 to p1d 0 ) must be externally pulled down or up so that current consumption does not increase due to noise. port 0d (p0d 3 /k 3 to p0d 0 /k 0 ) is internally pulled down. these pins are set in general-purpose output port mode. output contents are retained as is. therefore, current consumption increases if these pins are externally pulled down while they output high level, or pulled up while they output low level.
pd17012, 17p012 268 data sheet u10101ej4v0ds table 21-2. notes on status of each pin in halt and clock stop statuses (2/2) pin function pin symbol status of each pin and notes on processing halt clock stop lcd segment lcd 19 /p2h 0 lcd 18 /p2g 0 lcd 17 /p2f 0 lcd 16 /p2e 0 lcd 15 /ks 15 /pya 15 | lcd 0 /ks 0 /pya 0 pll frequency vcol synthesizer vcoh eo crystal oscillator x in x out same as above general-purpose output ports applies if these pins are used in general-purpose output port mode. if they output key source signals, current consumption increases via port 0d (with pull-down resistor) if there is switch that is always on such as transistor switch and if 1 is output as key source data. all pins are set in lcd segment signal output mode and output low level (display off). current consumption increases during pll operation. these pins are as follows when pll is disabled. vcol and vcoh: internally pulled down eo: floated pll is automatically disabled when ce pin goes low. pll is disabled. these pins are as follows. vcol and vcoh: internally pulled down eo: floated current consumption changes due to oscillation waveform of crystal oscillator. current consumption decreases as oscillation amplitude increases. because oscillation amplitude is influenced by crystal resonator and load capacitor used, evaluation must be performed. x in pin is internally pulled down, and x out pin outputs high level.
pd17012, 17p012 269 data sheet u10101ej4v0ds 22. reset the reset function is used to initialize the device operation. 22.1 configuration of reset block figure 22-1 shows the configuration of the reset block. the device is reset in two ways: by applying supply voltage v dd (power-on reset or v dd reset) and by using the ce pin (ce reset). the power-on reset block consists of a voltage detector that detects a voltage input to the v dd pin, a power failure detector, and a reset controller. the ce reset block consists of a circuit that detects the rising of a signal input to the ce pin, and a reset controller. figure 22-1. configuration of reset block selector basic timer 0 carry divider reset controller control register system register stack program counter forced halt by basic timer 0 carry reset signal ires res reset stop instruction rising detector voltage detector basic timer 0 carry disable ff r s q btm0cy flag read stop s instruction power-on-clear signal (poc) power failure detection block x out x in v dd ce timer ff block
pd17012, 17p012 270 data sheet u10101ej4v0ds 22.2 reset function power-on reset is effected when supply voltage v dd rises from a specific level, and ce reset is effected when the ce pin goes high. power-on reset initializes the program counter, stack, system register, and control registers, and executes the program from address 0000h. ce reset initializes the program counter, stack, system register, and some control registers, and executes the program from address 0000h. the major differences between power-on reset and ce reset are the control registers that are initialized and the operation of the power failure detector that is explained in 22.6 . both power-on reset and ce reset are controlled by the reset signals ires, res, and reset output from the reset controller shown in figure 22-1. table 22-1 shows the relationship between the ires, res, and reset signals, and power-on reset, and ce reset. the reset controller also operates when the clock stop instruction (stop s) explained in 21. standby is executed. the following sections 22.3 and 22.4 explain ce reset and power-on reset respectively. section 22.5 explains the relationship between ce reset and power-on reset. table 22-1. relationship between internal reset signals and each reset operation internal reset signal output signal control operation by each reset signal ce reset power-on clock stop reset ires forcibly sets device in halt status. halt status is released when basic timer 0 carry ff is set. res initializes some control registers. reset initializes program counter, stack, system register, and some control registers.
pd17012, 17p012 271 data sheet u10101ej4v0ds 22.3 ce reset ce reset is effected when the ce pin goes high. when the ce pin goes high, the reset signal is output in synchronization with the rising edge of the next basic timer 0 carry ff setting pulse, and the device is reset. when ce reset is effected, the reset signal initializes the program counter, stack, system register, and some control registers, and the program is executed starting from address 0000h. for the value to which each of the above registers is initialized, refer to the description of each register. the operation of ce reset differs depending on whether the clock stop instruction is used. the differences in operation are explained in the following subsections 22.3.1 and 22.3.2. subsection 22.3.3 explains the points to be noted on using ce reset. 22.3.1 ce reset when clock stop (stop s) instruction is not used figure 22-2 shows the operation of ce reset when the clock stop (stop s) instruction is not used. when the stop s instruction is not used, the basic timer clock select register of the control registers is not initialized. after the ce pin has gone high, therefore, the reset signal is output at the rising edge of the basic timer 0 carry ff setting pulse (1 ms, 5 ms, 100 ms, 250 ms) selected at that time, and the device is reset. figure 22-2. ce reset operation when clock stop instruction is not used 5 v 0 v h l h l h l h l h l h l v dd ce x out basic timer 0 carry ff setting pulse ires res reset normal operation normal operation ce reset is effected at rising of basic timer 0 carry ff setting pulse. if selected basic timer 0 carry ff setting time is t set , this period ??is 0 < t < t set depending on timing of rising of ce pin. during this period, program operation continues. reset signals
pd17012, 17p012 272 data sheet u10101ej4v0ds 22.3.2 ce reset when clock stop (stop s) instruction is used figure 22-3 shows the operation of ce reset when the clock stop (stop s) instruction is used. when the stop s instruction is used, the ires, res, and reset signals are output as soon as the stop s instruction has been executed. at this time, the basic timer clock select register of the control registers is initialized to 0000b by the res signal, the basic timer 0 carry ff setting signal is set to 100 ms. because the ires signal is output while the ce pin is low, the halt status, which can be released by the basic timer 0 carry, is forcibly set. however, the device stops operation because the clock is stopped. when the ce pin goes high, the clock stop status is released, and oscillation starts. because the halt status that can be released by the basic timer 0 carry is set at this time by the ires signal, the program starts from address 0 when the ce pin goes high and then the basic timer 0 carry ff setting pulse rises. because the basic timer 0 carry ff setting pulse is initialized to 100 ms, ce reset is effected 50 ms after the ce pin has gone high. figure 22-3. ce reset operation when clock stop instruction is used 5 v 0 v h l h l h l h l h l h l v dd ce x out ires res reset normal operation basic timer 0 carry ff setting pulse clock stop status halt status stop s instruction clock oscillation starts stop released ce reset program starts from address 0. 50 ms reset signals 22.3.3 notes on ce reset because ce reset is effected regardless of the instruction under execution, the following points <1> and <2> must be noted. (1) time to execute timer processing such as watch when developing a watch program by using basic timer 0 or basic timer 1, the processing of that program must be completed within a specific time. for details, refer to 12.2.6 notes on using basic timer 0 and 12.3.5 notes on using basic timer 1 . (2) processing of data and flag used for program care must be exercised in rewriting the contents of data or a flag that cannot be processed with one instruction and whose contents must not change even when ce reset is effected, such as a security code. this is explained in detail using the following examples.
pd17012, 17p012 273 data sheet u10101ej4v0ds example 1. r1 mem 0.01h ; first digit of key input data of security code r2 mem 0.02h ; second digit of key input data of security code r3 mem 0.03h ; first digit data for changing security code r4 mem 0.04h ; second digit data for changing security code m1 mem 0.11h ; first digit of current security code m2 mem 0.12h ; second digit of current security code start: key input processing r1 contents of key a ; security code input wait mode r2 contents of key b ; substitutes contents of pressed key into r1 and r2. set2 cmp, z ;<1> ; compares security code with input data. sub r1, m1 sub r2, m2 skt1 z br error ; input data is different from security code. main: key input processing r3 contents of key c ; security code rewriting mode r4 contents of key d ; substitutes contents of pressed key into r3 and r4. st m1, r3 ;<2> ; rewrites security code. st m2, r4 ;<3> br main error: must not operate suppose the current security code is 12h in the above program, the contents of data memory areas m1 and m2 are 1h and 2h , respectively. if ce reset is effected, the contents of the key input are compared with security code 12h in <1>. if they match, normal processing is performed. if the security code is changed by the main processing, the new code is written to m1 and m2 in <2> and <3>. suppose the security code is changed to 34h , 3h , and 4h are written to m1 and m2, respectively, in <2> and <3>. if a ce reset is effected at the point where <2> is executed, the program is executed from address 0000h without <3> being executed. consequently, the security code is changed to 32h , making it impossible to clear the security. in this case, use the program shown in example 2 below.
pd17012, 17p012 274 data sheet u10101ej4v0ds example 2. r1 mem 0.01h ; first digit of key input data of security code r2 mem 0.02h ; second digit of key input data of security code r3 mem 0.03h ; first digit data for changing security code r4 mem 0.04h ; second digit data for changing security code m1 mem 0.11h ; first digit of current security code m2 mem 0.12h ; second digit of current security code change flg 0.13h.0 ; 1 while security code is changed start: key input processing r1 contents of key a ; security code input wait mode r2 contents of key b ; substitutes contents of pressed key into r1 and r2. skt1 change ;<4> ; if change flag is 1 br security_chk st m1, r3 ; rewrites m1 and m2. st m2, r4 clr1 change security_chk: set2 cmp, z ;<1> ; compares security code with input data. sub r1, m1 sub r2, m2 skt1 z br error ; input data is different from security code. main: key input processing r3 contents of key c ; security code rewriting mode r4 contents of key d ; substitutes contents of pressed key into r3 and r4. set1 change ;<5> ; until security code is changed ; sets change flag to 1. st m1, r3 ;<2> ; rewrites security code st m2, r4 ;<3> clr1 change ; when security code has been changed, sets ; change flag to 0. br main error: must not operate in the program in example 2, the change flag is set to 1 in <5> before the security code is changed in <2> and <3>. therefore, the security code is rewritten in <4> even if a ce reset is effected before <3> is executed.
pd17012, 17p012 275 data sheet u10101ej4v0ds 22.4 power-on reset power-on reset is effected when the supply voltage v dd of the device rises from a specific level (called power- on-clear voltage). if the supply voltage v dd is lower than the power-on-clear voltage, a power-on clear signal (poc) is output from the voltage detector shown in figure 22-1. when the power-on-clear voltage is output, the crystal oscillator is stopped, and the device operation is stopped. while the power-on-clear signal is output, the ires, res, and reset signals are output. if supply voltage v dd exceeds the power-on-clear voltage, the power-on-clear signal is cleared, and crystal oscillation is started. at the same time, the ires, res, and reset signals are also cleared. at this time, the halt status is set to be released by the basic timer 0 carry due to the ires signal. therefore, power-on reset is effected at the rising edge of the next basic timer 0 carry ff setting signal. the basic timer 0 carry ff setting signal is initialized to 100 ms by the reset signal. for this reason, reset is effected 50 ms after supply voltage v dd has exceeded the power-on-clear voltage, and the program is started from address 0. this operation is illustrated in figure 22-4. the program counter, stack, system register, and control registers are initialized as soon as the power-on- clear signal has been output. for the value to which each of the above registers is to be initialized, refer to the description of each register. the power-on-clear voltage is 3.5 v (rated value) during normal operation, and 2.3 v (rated value) in the clock stop status. the operations performed when the power-on-clear voltage is at the respective levels are explained in 22.4.1 and 22.4.2 . the operation to be performed if the supply voltage v dd rises from 0 v is explained in 22.4.3 . figure 22-4. operation of power-on reset 5 v 0 v h l h l h l h l h l h v dd ce x out ires res reset normal operation basic timer 0 carry ff setting pulse device operation stops halt status power-on clear released oscillation starts power-on reset program starts from address 0. 50 ms l h l power-on clear signal power-on clear voltage reset signals
pd17012, 17p012 276 data sheet u10101ej4v0ds 22.4.1 power-on reset during normal operation figure 22-5 (a) shows the operation. as shown in the figure, the power-on-clear signal is output and the device operation stops regardless of the input level of the ce pin, if the supply voltage v dd drops below 3.5 v. if v dd rises beyond 3.5 v again, the program starts from address 0000h after 50 ms of halt status. normal operation is when the clock stop instruction is not used and includes the halt status that is set by the halt instruction. 22.4.2 power-on reset in clock stop status figure 22-5 (b) shows the operation. as shown in the figure, the power-on-clear signal is output and the device operation stops if supply voltage v dd drops below 2.3 v. however, it seems as if the device operation has not changed because the device is in the clock stop status. when supply voltage v dd rises beyond 3.5 v next time, the program starts from address 0000h after a 50 ms halt. 22.4.3 power-on reset when supply voltage v dd rises from 0 v figure 22-5 (c) shows the operation. as shown in the figure, the power-on-clear signal is output until supply voltage v dd rises from 0 v to 3.5 v. when v dd rises beyond the power-on-clear voltage, the crystal oscillator starts operating, and the program starts from address 0000h after a 50 ms halt.
pd17012, 17p012 277 data sheet u10101ej4v0ds figure 22-5. power-on reset and supply voltage v dd (a) during normal operation (including halt status) 5 v 0 v h l h l h v dd ce x out l power-on- clear signal power-on-clear voltage normal operation device operation stops halt status 50 ms power-on clear released oscillation starts power-on reset program starts from address 0. 3.5 v (b) in clock stop status 5 v 0 v h l h l h v dd ce x out l power-on- clear signal 2.3 v 3.5 v power-on-clear voltage normal operation device operation stops halt status 50 ms power-on clear released oscillation starts power-on reset program starts from address 0. stop s instruction clock stop (c) when supply voltage v dd rises from 0 v 5 v 0 v h l h l h v dd ce x out l power-on- clear signal power-on-clear voltage 3.5 v device operation stops halt status 50 ms power-on clear released oscillation starts power-on reset program starts from address 0.
pd17012, 17p012 278 data sheet u10101ej4v0ds 22.5 relationship between ce reset and power-on reset there is a possibility that power-on reset and ce reset are effected at the same time when power is first applied. the reset operations performed at this time are explained in 22.5.1 through 22.5.3 . 22.5.4 explains the points to be noted in raising supply voltage v dd . 22.5.1 if v dd pin and ce pin rise simultaneously figure 22-6 (a) shows the operation. at this time, the program starts from address 0000h due to power-on reset. 22.5.2 if ce pin rises in forced halt status of power-on reset figure 22-6 (b) shows the operation. at this time, the program starts from address 0000h due to power-on reset in the same manner as in 22.5.1 . 22.5.3 if ce pin rises after power-on reset figure 22-6 (c) shows the operation. at this time, the program starts from address 0000h due to power-on reset, and the program starts from address 0000h again at the rising of the next basic timer 0 carry ff setting signal because of ce reset.
pd17012, 17p012 279 data sheet u10101ej4v0ds figure 22-6. relationship between power-on reset and ce reset (a) if v dd and ce pins rise simultaneously 5 v 0 v h l h v dd ce l basic timer 0 carry ff setting pulse 3.5 v power-on-clear voltage halt status 50 ms normal operation power-on reset program starts operation stops (b) if ce pin rises in halt status 5 v 0 v h l h v dd ce l basic timer 0 carry ff setting pulse halt status 50 ms normal operation power-on reset program starts power-on-clear voltage 3.5 v operation stops (c) if ce pin rises after power-on reset 5 v 0 v h l h v dd ce l basic timer 0 carry ff setting pulse halt status 50 ms normal operation power-on reset program starts power-on-clear voltage 3.5 v ce reset program starts operation stops
pd17012, 17p012 280 data sheet u10101ej4v0ds 22.5.4 notes on raising supply voltage v dd when raising supply voltage v dd , keep in mind the following points (1) and (2). (1) when raising supply voltage v dd from power-on clear voltage it is necessary to raise supply voltage v dd to higher than 3.5 v at least once. this is illustrated in figure 22-7. suppose, for example, only a voltage less than 3.5 v is applied on application of v dd with a program that backs up v dd at 2.3 v by using the clock stop instruction, as shown in figure 22-7, the power-on-clear signal is continuously output, and the program does not operate. because the output ports of the device output undefined values, the current consumption increases in some cases. if the device is backed up by batteries, therefore, the back-up time is substantially shortened. figure 22-7. notes on raising v dd 5 v 0 v h l h v dd ce l basic timer 0 carry ff setting pulse h l h l 3.5 v 2.3 v x out power-on- clear signal operation stops opera- tion stops halt status 50 ms normal operation back up current consumption may increase during this period because output ports are undefined. power-on reset program starts stop s instruction power-on- clear voltage initialization is executed during this period, and then clock stop instruction is executed.
pd17012, 17p012 281 data sheet u10101ej4v0ds (2) restoring from clock stop status to restore the device from the back-up status while supply voltage v dd is backed up at 2.3 v by using the clock stop instruction, v dd must be raised to 3.5 v or higher within 50 ms after the ce pin has gone high. as shown in figure 22-8, the device is restored from the clock stop status by means of ce reset. because the power-on clear voltage is changed to 3.5 v 50 ms after the ce pin has gone high, power-on reset is effected unless v dd is 3.5 v or higher at this point. the same applies when v dd is lowered. figure 22-8. restoring from clock stop status 5 v 0 v h l h v dd ce l basic timer 0 carry ff setting pulse h l h l 3.5 v 2.3 v x out power-on- clear signal power-on- clear voltage back up by clock stop instruction halt status 50 ms normal operation processing where ce = low back up ce reset program starts stop s instruction power-on clear voltage is changed to 3.5 v at this point. therefore, v dd must rise to 3.5 v or higher before this point. power-on clear voltage is changed to 2.3 v at this point. therefore, v dd must not fall below 3.5 v before this point.
pd17012, 17p012 282 data sheet u10101ej4v0ds 22.6 power failure detection power failure detection is used to judge whether power-on reset by application of supply voltage v dd , or ce reset has been effected when the device is reset, as shown in figure 22-9. because the contents of the data memory and ports are undefined on power application, these contents are initialized by means of power failure detection. a power failure can be detected in two ways: by using the power failure detector to detect the btm0cy flag, and by detecting the contents of the data memory (ram judgement). 22.6.1 and 22.6.2 explain how a power failure is detected by using the power failure detector and btm0cy flag. 22.6.3 and 22.6.4 explain how a power failure is detected by ram judgement method. figure 22-9. power failure detection flow chart program starts power failure detection power failure not power failure initializes data memory and output ports 22.6.1 power failure detector the power failure detector consists of a voltage detector, a basic timer 0 carry disable flip-flop that is set by the output (power-on-clear signal) of the voltage detector, and a basic timer 0 carry, as shown in figure 22-1. the basic timer 0 carry disable ff is set to 1 by the power-on-clear signal, and is reset to 0 when an instruction that reads the btm0cy flag is executed. when the basic timer 0 carry disable ff is set to 1, the btm0cy flag is not set to 1. when the power-on-clear signal is output (at power-on reset), the program is started with the btm0cy flag reset, and the btm0cy flag is disabled from being set until an instruction that reads the btm0cy flag is executed. once the instruction that reads the btm0cy flag has been executed, the btm0cy flag is set each time the basic timer 0 carry ff setting pulses has risen. it can be judged whether power-on reset (power failure) or ce reset (not power failure) has been effected by detecting the contents of the btm0cy flag when the device is reset. power-on reset has been effected if the btm0cy flag is reset to 0; ce reset has been effected if it is set to 1. the voltage at which a power failure can be detected is the same as the voltage at which power-on reset is effected, or v dd = 3.5 v during crystal oscillation, or v dd = 2.3 v in the clock stop status. figure 22-10 shows the transition of the status of the btm0cy flag. figures 22-11 and 22-10 show the timing chart and the operation of the btm0cy flag.
pd17012, 17p012 283 data sheet u10101ej4v0ds figure 22-10. status transition of btm0cy flag ce = low ce = any ce = high <1> v dd = low operation stops crystal oscillation starts forced halt (approx. 50 ms) power-on reset <2> clock stop <5> ce reset normal operation stop 0 ce = h l disables setting of btm0cy flag. normal operation ce reset wait crystal oscillation starts forced halt (50 ms) skt1 btm0cy or skf1 btm0cy btm0cy = 0 basic timer 0 carry ff setting pulse rises. ce = l ce = h skt1 btm0cy or skf1 btm0cy ce = l h ce = l h clock stop ce reset stop 0 ce = h l enables setting of btm0cy flag normal operation ce reset wait crystal oscillation starts forced halt (50 ms) btm0cy = 1 basic timer 0 carry ff setting pulse rises. ce = l h ce = l h v dd = l 3.5 v <3> normal operation <7> <8> <9> <10> <11> <12> <13> normal operation normal operation <14> <15> <16> <17> <4> <6>
pd17012, 17p012 284 data sheet u10101ej4v0ds figure 22-11. operation of btm0cy flag (a) when btm0cy flag never detected (skt1 btm0cy or skf1 btm0cy is not executed) 5 v 0 v h l h l h v dd ce l basic timer 0 carry ff setting pulse btm0cy operation in figure 22-10 timer time changed stop 0000 b <1> <2> <6> <8> <6> <5> <4> <9> <6> <1> <7> <7> <3> <5> (b) when detecting power failure by btm0cy flag 5 v 0 v h l h l h v dd ce l basic timer 0 carry ff setting pulse btm0cy operation in figure 22-10 timer time changed stop 0000 b btm0cy = 0 power failure btm0cy = 1 no power failure btm0cy = 1 no power failure <1> <2> <6> <14> <13> <16> <14> <13> <12> <17> <14> <1> <15> <15> <3> <11> skti instruction
pd17012, 17p012 285 data sheet u10101ej4v0ds 22.6.2 notes on detecting power failure by btm0cy flag the following points must be noted when using the btm0cy flag for watch counting. (1) updating watch when developing a watch program by using the basic timer 0 carry, the watch must be updated after a power failure has been detected. this is because counting of the watch is skipped once because the btm0cy flag is reset to 0 when the btm0cy flag is read on detection of a power failure. (2) watch updating processing time the processing to update the watch must be completed before the next basic timer 0 carry ff setting pulse rises. this is because, if the ce pin goes high during the watch updating processing, ce reset is effected without the watch updating processing completed. for further information on (1) and (2) above, refer to 12.2.6 (3) correction of basic timer 0 carry on ce reset . when detecting a power failure, the following points must be noted. (3) timing of power failure detection to count the watch by using the btm0cy flag, the btm0cy flag must be read to detect a power failure within the time since the program has started from address 0000h until the next basic timer 0 carry ff setting pulse rises. for example if the basic timer 0 carry ff setting time is set to 5 ms, and a power failure is detected 6 ms after the program has been started, the btm0cy flag is overlooked once. for details, refer to 12.2.6 (3) correction of basic timer 0 carry on ce reset . power failure detection and initial processing must be completed within the basic timer 0 carry ff setting time as shown in the following example. this is because, if the ce pin goes high and ce reset is effected during power failure detection processing and initial processing, these processing may be stopped in midway, and thus problems may occur. to change the basic timer 0 carry ff setting time by the initial processing, the instruction that changes the time must be executed at the end of the initial processing, and the instruction must be one instruction. this is because the initial processing may not be completely executed because of ce reset if the basic timer 0 carry ff setting time is changed before the initial processing is executed, as shown in the following example.
pd17012, 17p012 286 data sheet u10101ej4v0ds example start: ; program address 0000h ;<1> processing on reset ;<2> skt1 btm0cy ; power failure detection br initial backup: ;<3> watch updating br main initial: ;<4> initial processing ;<5> initflg btm0ck1, not btm0ck0 ; embedded macro ; sets basic timer 0 carry ff setting time to 5 ms main: main processing skt1 btm0cy br main watch updating br main
pd17012, 17p012 287 data sheet u10101ej4v0ds example of operation 5 v 0 v h l h l v dd ce basic timer 0 carry ff setting pulse 50 ms 5 ms <2> power failure detection if processing time of <1> + <4> is longer than 100 ms, ce reset is effected in middle of processing <4>. if processing time of <1> + <3> is too long, ce reset is effected. < 5 > ce reset ce reset 50 ms 5 ms pulse 50 ms pulse <1> <4> <1> <3> <2> power failure detection ce reset may be effected immediately depending on when basic timer 0 carry ff setting time is changed. therefore, if <5> is executed before <4>, power failure processing <4> may not be completely executed. 22.6.3 power failure detection by ram judgement method the ram judgement method is to detect a power failure by judging whether the contents of the data memory at a specific address are the specified value. an example of a program that detects a power failure by the ram judgement method is shown below. the ram judgement method detects a power failure by comparing an undefined value with the specified value because the contents of the data memory are undefined on application of supply voltage v dd . therefore, there is a possibility that a wrong judgment may be made as explained in 22.6.4 notes on detecting power failure by ram judgement method .
pd17012, 17p012 288 data sheet u10101ej4v0ds example program to detect power failure by ram judgement method m012 mem 0.12h m034 mem 0.34h m056 mem 0.56h m107 mem 1.07h m128 mem 1.28h m16f mem 1.6fh data0 dat 1010b data1 dat 0101b data2 dat 0110b data3 dat 1001b data4 dat 1100b data5 dat 0011b start: set2 cmp, z sub m012, #data0 ; if m012 = data0 and sub m034, #data1 ; m034 = data1 and sub m056, #data2 ; m056 = data2 and bank1 sub m107, #data3 ; m107 = data3 and sub m128, #data4 ; m128 = data4 and sub m16f, #data5 ; m16f = data5, bank0 skf1 z br backup ; branches to backup ;initial: initial processing mov m012, #data0 mov m034, #data1 mov m056, #data2 bank1 mov m107, #data3 mov m128, #data4 mov m16f, #data5 br main backup: backup processing main: main processing
pd17012, 17p012 289 data sheet u10101ej4v0ds 22.6.4 notes on detecting power failure by ram judgement method the value of the data memory on application of supply voltage v dd is basically undefined, and therefore, the following points (1) and (2) must be noted. (1) data to be compared where the number of bits of the data memory to be compared by the ram judgement method is n bits , the probability at which the value of the data memory matches the value to be compared on application of v dd is (1/2) n . this means that backup is judged at a probability of (1/2) n when a power failure is detected by the ram judgement method. to lower this probability, as many bits as possible must be compared. because the contents of the data memory on application of v dd are likely to be the same value such as 0000b and 1111b , it is recommended to mix 0 and 1 as data to be compared, such a 1010b and 0110b to reduce the possibility of a wrong judgment. (2) notes on program if v dd rises from the level at which the data memory contents may be destroyed as shown in figure 22- 12, and even if the value of the data memory area to be compared is normal, the values of the other data memory areas may be destroyed. this is judged as backup if a power failure is detected by the ram judgement method. therefore, consideration must be given so that the program does not hang up even if the contents of the data memory are destroyed. figure 22-12. v dd and destruction of data memory contents data memory destruction start voltage 5 v 0 v v dd values of data memory areas not used for ram judgement may be destroyed. data memory for ram judgement (normal) data memory
pd17012, 17p012 290 data sheet u10101ej4v0ds 23. instruction set 23.1 outline of instruction set b 14 to b 11 b 15 01 bin hex 0000 0 add r, m add m, #n4 0001 1 sub r, m sub m, #n4 0010 2 addc r, m addc m, #n4 0011 3 subc r, m subc m, #n4 0100 4 and r, m and m, #n4 0101 5 xor r, m xor m, #n4 0110 6 or r, m or m, #n4 0111 7 inc ar inc ix rorc r movt dbf, @ar push ar pop ar get dbf, p put p, dbf peek wr, rf poke rf, wr br @ar call @ar ret retsk reti ei di stop s halt h nop 1000 8 ld r, m st m, r 1001 9 ske m, #n4 skge m, #n4 1010 a mov @r, m mov m, @r 1011 b skne m, #n4 sklt m, #n4 1100 c br addr (page 0) call addr (page 0) 1101 d br addr (page 1) mov m, #n4 1110 e skt m, #n 1111 f skf m, #n
pd17012, 17p012 291 data sheet u10101ej4v0ds 23.2 legend ar: address register asr: address stack register indicated by stack pointer addr: program memory address (lower 11 bits) bank: bank register cmp: compare flag cy: carry flag dbf: data buffer h: halt release condition intef: interrupt enable flag intr: register automatically saved to stack when interrupt occurs intsk: interrupt stack register ix: index register mp: data memory row address pointer mpe: memory pointer enable flag m: data memory address indicated by m r , m c m r : data memory row address (higher) m c : data memory column address (lower) n: bit position (4 bits) n4: immediate data (4 bits) page: page (bit 11 of program counter) pc: program counter p: peripheral address p h : peripheral address (higher 3 bits) p l : peripheral address (lower 4 bits) r: general register column address rf: register file address r fr : register file address (higher 3 bits) n fc : register file address (lower 4 bits) sp: stack pointer s: stop release condition wr: window register ( ): contents addressed by
pd17012, 17p012 292 data sheet u10101ej4v0ds 23.3 instruction set list instructions mnemonic operand operation instruction code op code operand add add r, m (r) (r) + (m) 00000 m r m c r m, #n4 (m) (m) + n4 10000 m r m c n4 addc r, m (r) (r) + (m) + cy 00010 m r m c r m, #n4 (m) (m) + n4 + cy 10010 m r m c n4 inc ar ar ar + 1 00111 000 1001 0000 ix ix ix + 1 00111 000 1000 0000 subtract sub r, m (r) (r) ?(m) 00001 m r m c r m, #n4 (m) (m) ?n4 10001 m r m c n4 subc r, m (r) (r) ?(m) ?cy 00011 m r m c r m, #n4 (m) (m) ?n4 ?cy 10011 m r m c n4 logical or r, m (r) (r) (m) 00110 m r m c r operation m, #n4 (m) (m) n4 10110 m r m c n4 and r, m (r) (r) (m) 00100 m r m c r m, #n4 (m) (m) n4 10100 m r m c n4 xor r, m (r) (r) (m) 00101 m r m c r m, #n4 (m) (m) n4 10101 m r m c n4 judge skt m, #n cmp 0, if (m) n = n, then skip 11110 m r m c n skf m, #n cmp 0, if (m) n = 0, then skip 11111 m r m c n compare ske m, #n4 (m) ?n4, skip if zero 01001 m r m c n4 skne m, #n4 (m) ?n4, skip if not zero 01011 m r m c n4 skge m, #n4 (m) ?n4, skip if not borrow 11001 m r m c n4 sklt m, #n4 (m) ?n4, skip if borrow 11011 m r m c n4 rotate rorc r cy (r) b3 (r) b2 (r) b1 (r) b0 00111 000 0111 r transfer ld r, m (r) (m) 01000 m r m c r st m, r (m) (r) 11000 m r m c r mov @r, m if mpe = 1: (mp, (r)) (m) 01010 m r m c r if mpe = 0: (bank, m r , (r)) (m) m, @r if mpe = 1: (m) (mp, (r)) 11010 m r m c r if mpe = 0: (m) (bank, m r , (r)) m, #n4 (m) n4 11101 m r m c n4 movt dbf, @ar sp sp ?1, asr pc, pc ar, 00111 000 0001 0000 dbf (pc), pc asr, sp sp + 1 push ar sp sp ?1, asr ar 00111 000 1101 0000 pop ar ar asr, sp sp + 1 00111 000 1100 0000 peek wr, rf wr (rf) 00111 rf r 0011 rf c
pd17012, 17p012 293 data sheet u10101ej4v0ds instructions mnemonic operand operation instruction code op code operand transfer poke rf, wr (rf) wr 00111 rf r 0010 rf c get dbf, p dbf (p) 00111 p h 1011 p l put p, dbf (p) dbf 00111 p h 1010 p l branch br addr pc 10 ?0 addr, page 0 01100 addr pc 10 ?0 addr, page 1 01101 @ar pc ar 00111 000 0100 0000 subroutine call addr sp sp ?1, asr pc 11100 addr pc 10 ?0 addr, page 0 @ar sp sp ?1, asr pc 00111 000 0101 000 pc ar ret pc asr, sp sp + 1 00111 000 1110 0000 retsk pc asr, sp sp + 1 and skip 00111 001 1110 0000 reti pc asr, intr intsk, sp sp + 1 00111 010 1110 0000 interrupt ei intef 1 00111 000 1111 0000 di intef 0 00111 001 1111 0000 others stop s stop 00111 010 1111 s halt h halt 00111 011 1111 h nop no operation 00111 100 1111 0000
pd17012, 17p012 294 data sheet u10101ej4v0ds 23.4 assembler (ra17k) embedded macro instructions legend flag n: flg symbol n: bit number < >: can be omitted mnemonic operand operation n embedded sktn flag 1, ... flag n if (flag 1) to (flag n) = all ?? then skip 1 n 4 macro skfn flag 1, ... flag n if (flag 1) to (flag n) = all ?? then skip 1 n 4 setn flag 1, ... flag n (flag 1) to (flag n) 11 n 4 clrn flag 1, ... flag n (flag 1) to (flag n) 01 n 4 notn flag 1, ... flag n if (flag n) = ?? then (flag n) 11 n 4 if (flag n) = ?? then (flag n) 0 initflg flag 1, if description = not flag n, then (flag n) 01 n 4 ... < flag n> if description = flag n, then (flag n) 1 bankn (bank) n0 n 2
pd17012, 17p012 295 data sheet u10101ej4v0ds 24. reserved symbols 24.1 data buffer (dbf) symbol name attribute value r/w description dbf3 mem 0.0ch r/w bits 15 through 12 of dbf dbf2 mem 0.0dh r/w bits 11 through 8 of dbf dbf1 mem 0.0eh r/w bits 7 through 4 of dbf dbf0 mem 0.0fh r/w bits 3 through 0 of dbf 24.2 system register (sysreg) symbol name attribute value r/w description ar3 mem 0.74h r bits 15 through 12 of address register ar2 mem 0.75h r bits 11 through 8 of address register ar1 mem 0.76h r/w bits 7 through 4 of address register ar0 mem 0.77h r/w bits 3 through 0 of address register wr mem 0.78h r/w window register bank mem 0.79h r/w bank register ixh mem 0.7ah r/w index register, high mph mem 0.7ah r/w memory pointer, high mpe flg 0.7ah.3 r/w memory pointer enable flag ixm mem 0.7bh r/w index register, middle mpl mem 0.7bh r/w memory pointer, low ixl mem 0.7ch r/w index register, low rph mem 0.7dh r/w general register pointer, high rpl mem 0.7eh r/w general register pointer, low psw mem 0.7fh r/w program status word bcd flg 0.7eh.0 r/w bcd operation flag cmp flg 0.7fh.3 r/w compare flag cy flg 0.7fh.2 r/w carry flag z flg 0.7fh.1 r/w zero flag ixe flg 0.7fh.0 r/w index enable flag
pd17012, 17p012 296 data sheet u10101ej4v0ds 24.3 lcd segment register symbol name attribute value r/w description lcdd0 mem 2.6f r/w lcd segment register lcdd1 mem 2.6e r/w lcd segment register lcdd2 mem 2.6d r/w lcd segment register lcdd3 mem 2.6c r/w lcd segment register lcdd4 mem 2.6b r/w lcd segment register lcdd5 mem 2.6a r/w lcd segment register lcdd6 mem 2.69 r/w lcd segment register lcdd7 mem 2.68 r/w lcd segment register lcdd8 mem 2.67 r/w lcd segment register lcdd9 mem 2.66 r/w lcd segment register lcdd10 mem 2.65 r/w lcd segment register lcdd11 mem 2.64 r/w lcd segment register lcdd12 mem 2.63 r/w lcd segment register lcdd13 mem 2.62 r/w lcd segment register lcdd14 mem 2.61 r/w lcd segment register lcdd15 mem 2.60 r/w lcd segment register lcdd16 mem 2.5fh r/w lcd segment register lcdd17 mem 2.5eh r/w lcd segment register lcdd18 mem 2.5dh r/w lcd segment register lcdd19 mem 2.5ch r/w lcd segment register
pd17012, 17p012 297 data sheet u10101ej4v0ds ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ 24.4 port register symbol name attribute value r/w description p0a2 flg 0.70h.2 r/w bit 2 of port 0a p0a1 flg 0.70h.1 r/w bit 1 of port 0a p0a0 flg 0.70h.0 r/w bit 0 of port 0a p0b3 flg 0.71h.3 r/w bit 3 of port 0b p0b2 flg 0.71h.2 r/w bit 2 of port 0b p0b1 flg 0.71h.1 r/w bit 1 of port 0b p0b0 flg 0.71h.0 r/w bit 0 of port 0b p0c3 flg 0.72h.3 r/w bit 3 of port 0c p0c2 flg 0.72h.2 r/w bit 2 of port 0c p0c1 flg 0.72h.1 r/w bit 1 of port 0c p0c0 flg 0.72h.0 r/w bit 0 of port 0c p0d3 flg 0.73h.3 r bit 3 of port 0d p0d2 flg 0.73h.2 r bit 2 of port 0d p0d1 flg 0.73h.1 r bit 1 of port 0d p0d0 flg 0.73h.0 r bit 0 of port 0d p1a2 flg 1.70h.2 r/w bit 2 of port 1a p1a1 flg 1.70h.1 r/w bit 1 of port 1a p1a0 flg 1.70h.0 r/w bit 0 of port 1a p1b3 flg 1.71h.3 r/w bit 3 of port 1b p1b2 flg 1.71h.2 r/w bit 2 of port 1b p1b1 flg 1.71h.1 r/w bit 1 of port 1b p1b0 flg 1.71h.0 r/w bit 0 of port 1b p1c3 flg 1.72h.3 r/w bit 3 of port 1c p1c2 flg 1.72h.2 r/w bit 2 of port 1c p1c1 flg 1.72h.1 r/w bit 1 of port 1c p1c0 flg 1.72h.0 r/w bit 0 of port 1c p1d3 flg 1.73h.3 r bit 3 of port 1d p1d2 flg 1.73h.2 r bit 2 of port 1d p1d1 flg 1.73h.1 r bit 1 of port 1d p1d0 flg 1.73h.0 r bit 0 of port 1d p2e0 flg 2.5fh.0 r/w bit 0 of port 2e p2f0 flg 2.5eh.0 r/w bit 0 of port 2f p2g0 flg 2.5dh.0 r/w bit 0 of port 2g p2h0 flg 2.5ch.0 r/w bit 0 of port 2h
pd17012, 17p012 298 data sheet u10101ej4v0ds 24.5 register file (control register) symbol name attribute value r/w description sp mem 0.81h r/w stack pointer sio1ts flg 0.82h.3 r/w serial interface start flag sio1hiz flg 0.82h.2 r/w p0a 1 /so 1 pin select flag sio1ck1 flg 0.82h.1 r/w serial interface clock select flag sio1ck0 flg 0.82h.0 r/w serial interface clock select flag ifcg flg 0.84h.0 r if counter gate status flag pllul flg 0.85h.0 r pll unlock ff flag adccmp flg 0.86h.0 r adc judge flag ce flg 0.87h.0 r ce pin status flag btm1ck1 flg 0.89h.3 r/w basic timer 0 clock select flag btm1ck0 flg 0.89h.2 r/w basic timer 0 clock select flag btm0ck1 flg 0.89h.1 r/w basic timer 1 clock select flag btm0ck0 flg 0.89h.0 r/w basic timer 1 clock select flag tmck flg 0.8ch.0 r/w 12-bit timer clock select flag tmovf flg 0.8dh.0 r timer/counter overflow detector flag tmrpt flg 0.8eh.2 r/w 12-bit timer mode select flag tmres flg 0.8eh.1 r/w timer/counter reset flag tmen flg 0.8eh.0 r/w timer/counter start/stop flag ksen flg 0.90h.2 r/w key source latch enable flag lcden flg 0.90h.1 r/w lcd enable flag pyasel flg 0.90h.0 r/w port ya select flag p2hsel flg 0.91h.3 r/w port 2h select flag p2gsel flg 0.91h.2 r/w port 2g select flag p2fsel flg 0.91h.1 r/w port 2f select flag p2esel flg 0.91h.0 r/w port 2e select flag ifcmd1 flg 0.92h.3 r/w if counter mode select flag ifcmd0 flg 0.92h.2 r/w if counter mode select flag ifcck1 flg 0.92h.1 r/w if counter clock select flag ifcck0 flg 0.92h.0 r/w if counter clock select flag pwm1sel flg 0.93h.1 r/w p0c 1 /pwm 1 pin select flag pwm0sel flg 0.93h.0 r/w p0c 0 /pwm 0 pin select flag adcch1 flg 0.94h.1 r/w a/d converter channel select flag adcch0 flg 0.94h.0 r/w a/d converter channel select flag beep1sel flg 0.95h.1 r/w p0b 1 /beep 1 pin select flag beep0sel flg 0.95h.0 r/w p0b 0 /beep 0 pin select flag keyj flg 0.96h.0 r key input judge flag ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------
pd17012, 17p012 299 data sheet u10101ej4v0ds symbol name attribute value r/w description btm0cy flg 0.97h.0 r basic timer 0 carry flag ieg flg 0.9fh.0 r/w int pin interrupt edge select flag pllmd1 flg 0.0a1h.1 r/w pll mode select flag pllmd0 flg 0.0a1h.0 r/w pll mode select flag ifcstrt flg 0.0a3h.1 r/w if counter start flag ifcres flg 0.0a3h.0 r/w if counter reset flag fcgch1 flg 0.0a4h.1 r/w external gate counter channel select flag fcgch0 flg 0.0a4h.0 r/w external gate counter channel select flag beep1ck1 flg 0.0a5h.3 r/w beep 1 clock select flag beep1ck0 flg 0.0a5h.2 r/w beep 1 clock select flag beep0ck1 flg 0.0a5h.1 r/w beep 0 clock select flag beep0ck0 flg 0.0a5h.0 r/w beep 0 clock select flag p1dgio flg 0.0a7h.0 r/w port 1d group i/o select flag ipsio1 flg 0.0afh.3 r/w serial interface interrupt enable flag ipbtm1 flg 0.0afh.2 r/w basic timer 1 interrupt enable flag iptm flg 0.0afh.1 r/w 12-bit timer interrupt enable flag ip flg 0.0afh.0 r/w int pin interrupt enable flag pllrfck3 flg 0.0b1h.3 r/w pll reference clock select flag pllrfck2 flg 0.0b1h.2 r/w pll reference clock select flag pllrfck1 flg 0.0b1h.1 r/w pll reference clock select flag pllrfck0 flg 0.0b1h.0 r/w pll reference clock select fla p1abio2 flg 0.0b5h.2 r/w i/o select flag of p1a 2 pin p1abio1 flg 0.0b5h.1 r/w i/o select flag of p1a 1 pin p1abio0 flg 0.0b5h.0 r/w i/o select flag of p1a 0 pin p0bbio3 flg 0.0b6h.3 r/w i/o select flag of p0b 3 pin p0bbio2 flg 0.0b6h.2 r/w i/o select flag of p0b 2 pin p0bbio1 flg 0.0b6h.1 r/w i/o select flag of p0b 1 pin p0bbio0 flg 0.0b6h.0 r/w i/o select flag of p0b 0 pin p0abio2 flg 0.0b7h.2 r/w i/o select flag of p0a 2 pin p0abio1 flg 0.0b7h.1 r/w i/o select flag of p0a 1 pin p0abio0 flg 0.0b7h.0 r/w i/o select flag of p0a 0 pin irqsio1 flg 0.0bch.0 r/w serial interface interrupt request flag irqbtm1 flg 0.0bdh.0 r/w basic timer 1 interrupt request flag irqtm flg 0.0beh.0 r/w 12-bit timer interrupt request flag int flg 0.0bfh.3 r int pin interrupt status flag irq flg 0.0bfh.0 r/w int pin interrupt request flag ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ----------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------
pd17012, 17p012 300 data sheet u10101ej4v0ds 24.6 peripheral hardware register symbol name attribute value r/w description adcr dat 02h r/w a/d converter reference voltage setting register sio1sfr dat 03h r/w serial interface presettable shift register pwmr0 dat 04h r/w pwm 0 data register pwmr1 dat 05h r/w pwm 1 data register ar dat 40h r/w address register pllr dat 41h r/w pll data register ksr dat 42h r/w key source data register pya dat 42h r/w pya group register ifc dat 43h r if counter data register tmm dat 46h r/w timer modulo register tmc dat 47h r timer counter 24.7 others symbol name attribute value description dbf dat 0fh fixed operand value of put, get, and movt instructions ix dat 01h fixed operand value of inc instruction ------------------------------------------------------------------------------------------------------
pd17012, 17p012 301 data sheet u10101ej4v0ds 25. one-time prom (program memory) write and verify ( pd17p012 only) the pd17p012 includes a 4,096 16-bit one-time prom program memory. the pins used for the write/verify operations of this one-time prom are listed in table 25-1. clock input from the clk pin, instead of address input, is used for updating addresses. table 25-1. pins used for program memory write/verify pin name function v pp pin used to apply the program voltage when writing, reading, or verifying the program memory. apply +12.5 v. v dd1 , v dd2 power supply. supply +6 v to these pins when writing, reading, or verifying the program memory. clk clock input to update addresses when writing, reading, or verifying the program memory. program memory addresses are updated by inputting a pulse to the clk pin four times. md 0 to md 3 input to select the operation mode when writing, reading, or verifying the program memory. d 0 to d 7 8-bit data i/o when writing, reading, or verifying the program memory. 25.1 operation modes for program memory write/verify when +6 v is applied to the v dd pin and +12.5 v to the v pp pin after the reset status (v dd = 5 v and reset = 0 v) has continued for a certain time, the pd17p012 enters the program memory write/verify mode. the following operation modes can be set by setting pins md 0 to md 3 as shown below. pins not listed in table 25-1 should be left open, or connected to gnd via a pull-down resistor (470 ? ) (refer to pin configuration (2) pd17p012 (b) prom programming mode ). table 25-2. operation mode setting operation mode setting operation mode v pp v dd md 0 md 1 md 2 md 3 +12.5 v +6 v h l h l program memory address 0-clear mode l h h h write mode l l h h verify mode h h h program inhibit mode : don? care (l or h)
pd17012, 17p012 302 data sheet u10101ej4v0ds 25.2 program memory write procedure program memory can be written at high speed using the following procedure. (1) pull down unused pins via a resistor. set the clk pin to low. (2) supply 5 v to the v dd pin. set the v pp pin to low. (3) wait for 10 s and then supply 5 v to the v pp pin. (4) set the mode setting pin to program memory address 0-clear mode. (5) supply +6 v to the v dd pin and +12.5 v to the v pp pin. (6) set the program inhibit mode. (7) write data in the 1 ms write mode. (8) set the program inhibit mode. (9) set the verify mode. if the data is correct, go to step (10). if not, repeat steps (7) to (9). (10) (x: number of write operations from steps (7) to (9)) 1 ms additional write. (11) set the program inhibit mode. (12) input four pulses to the clk pin to increment the program memory address by one. (13) repeat steps (7) to (12) until the end address is reached. (14) set the program memory address 0-clear mode. (15) change the v dd and v pp pins to 5 v. (16) turn off the power. the following figure shows steps (2) to (12). write verify additional write address increment reset x repetitions ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? data input data output data input v pp v dd gnd v dd + 1 v dd gnd clk hi-z hi-z hi-z hi-z md 0 d 0 to d 7 md 1 md 2 md 3 v dd v pp
pd17012, 17p012 303 data sheet u10101ej4v0ds 25.3 program memory read procedure (1) pull down unused pins to gnd via a resistor. set the clk pin to low. (2) supply 5 v to the v dd pin. set the v pp pin to low. (3) wait for 10 s and then supply 5 v to the v pp pin. (4) set the mode setting pin to program memory address 0-clear mode. (5) supply +6 v to the v dd pin and +12.5 v to the v pp pin. (6) set the program inhibit mode. (7) set the verify mode. addresses are incremented by one for each 4-pulse cycle input to the clk pin. (8) set the program inhibit mode. (9) set the program memory address 0-clear mode. (10) change the v dd and v pp pins to 5 v. (11) turn off the power. the following figure shows steps (2) to (9). hi-z hi-z l md 3 md 2 md 1 md 0 clk d 0 to d 7 gnd v dd v dd v pp v pp v dd gnd v dd + 1 reset data output data output one cycle
pd17012, 17p012 304 data sheet u10101ej4v0ds 26. electrical specifications absolute maximum ratings (t a = 25 c) parameter symbol condition rating unit supply voltage v dd pd17012 ? 0.3 to +6.0 v pd17p012 ? 0.3 to +6.3 v prom program voltage v pp pd17p012 ? 0.3 to +13.5 v input voltage v i ? 0.3 to v dd + 0.3 v output voltage v o other than p0c 0 to p0c 3 ? 0.3 to v dd + 0.3 v output breakdown voltage v bds p0c 0 to p0c 3 ( pd17012) 14.0 v p0c 0 to p0c 3 ( pd17p012) 10.0 v output current, high i oh per pin ? 12 ma total for all pins ? 20 ma output current, low i ol per pin 15 ma total for all pins 30 ma overall error p t 200 mw operating ambient temperature t a when overall function operates ? 40 to +85 c storage temperature t stg ? 55 to +125 c caution product quality may suffer if the absolute maximum rating is exceeded even momentarily for any parameter. that is, the absolute maximum ratings are rated values at which the product is on the verge of suffering physical damage, and therefore the product must be used under conditions that ensure that the absolute maximum ratings are not exceeded. recommended operating conditions parameter symbol condition min. typ. max. unit supply voltage v dd1 when overall function operate 4.5 5.0 5.5 v v dd2 when pll stops and cpu operates 3.5 5.0 5.5 v data retention voltage v ddr when crystal oscillation stops 2.3 5.5 v output breakdown voltage v bds p0c 0 to p0c 3 ( pd17012) 12.0 v p0c 0 to p0c 3 ( pd17p012) 9.0 v operating ambient temperature t a ? 40 +85 c supply voltage rise time t rise v dd : 0 4.5 v 500 ms v dd : 2.3 3.5 v 50 ms input amplitude v in1 vcoh, vcol 0.5 v dd v p-p v in2 amifc, fmifc 0.5 v dd v p-p
pd17012, 17p012 305 data sheet u10101ej4v0ds dc characteristics (t a = ? 40 to +85 c, v dd = 4.5 to 5.5 v) parameter symbol conditions min. typ. max. unit supply current i dd1 with cpu operating, pll stopped, sine wave input to 1.0 2.0 ma ( pd17012) x in pin (f in = 4.5 mhz, v in = v dd ) i dd2 with cpu operating, pll stopped, sine wave input to 0.5 1.0 ma x in pin (f in = 4.5 mhz, v in = v dd ) halt instruction used supply current i dd1 with cpu operating, pll stopped, sine wave input to 2.5 3.5 ma ( pd17p012) x in pin (f in = 4.5 mhz, v in = v dd ) i dd2 with cpu operating, pll stopped, sine wave input to 2.0 3.0 ma x in pin (f in = 4.5 mhz, v in = v dd ) halt instruction used data retention voltage v ddr1 with crystal oscillation power failure detection by timer ff 3.5 v v ddr2 with crystal power failure detection by timer ff 2.3 v v ddr3 oscillation stopped data memory retained 2.0 v data retention current i ddr1 with crystal v dd = 5 v, t a = 25 c 2.0 4.0 a i ddr2 oscillation stopped 2.0 20.0 a i ddr3 v dd = 2.3 v, t a = 25 c 1.0 2.0 a i ddr4 v dd = 2.3 v 1.0 10.0 a intermediate-level output v om com 0 to com 2 v dd = 5.0 v 2.3 2.7 v voltage input voltage, high v ih1 p0a 1 , p0b 0 to p0b 3 , p1a 0 to p1a 2 , p1b 0 to p1b 3 , 0.7v dd v dd v p1d 0 to p1d 3 v ih2 p0a 0 , p0a 2 , ce, int 0.8v dd v dd v v ih3 p0d 0 to p0d 3 0.6v dd v dd v input voltage, low v il1 p0a 1 , p0b 0 to p0b 3 , p0d 0 to p0d 3 , p1a 0 to p1a 2 , 0 0.2v dd v p1b 0 to p1b 3 , p1c 0 to p1c 3 note , p1d 0 to p1d 3 v il2 p0a 0 , p0a 2 , ce, int 0 0.2v dd v output current, high i oh1 p0a 0 to p0a 2 , p0b 0 to p0b 3 , p1a 0 to p1a 2 , ? 1.0 ma p1c 0 to p1c 3 , p1d 0 to p1d 3 v oh = v dd ? 1 v i oh2 lcd 0 to lcd 19 , eo v oh = v dd ? 1 v ? 1.0 ma output current, low i ol1 p0a 0 to p0a 2 , p0b 0 to p0b 3 , p1a 0 to p1a 2 , 1.0 ma p1c 0 to p1c 3 , p1d 0 to p1d 3 v ol = 1 v i ol2 lcd 0 to lcd 19 , eo v ol = 1 v 1.0 ma i ol3 p0c 0 to p0c 3 v ol = 1 v 1.0 ma input current, high i ih1 vcoh pin pulled down v ih = v dd 10 ma i ih2 vcol pin pulled down v ih = v dd 0.1 ma i ih3 x in pin pulled down v ih = v dd 0.1 ma i ih4 p0d 0 to p0d 3 pin pulled down v ih = v dd 10 150 a output off leakage i l1 p0c 0 to p0c 3 ( pd17012) v oh = 12 v 1.0 a current p0c 0 to p0c 3 ( pd17p012) v oh = 9 v 1.0 a i l2 eo v oh = v dd , v ol = 0 v 1.0 a note during prom programming mode
pd17012, 17p012 306 data sheet u10101ej4v0ds ac characteristics (t a = ?0 to +85 c, v dd = 4.5 to 5.5 v) parameter symbol conditions min. typ. max. unit operating frequency f in1 vcol pin, mf mode, 0.90 3.0 mhz ( pd17012) sine wave input v in = 0.15 v p-p vcol pin, mf mode, 0.50 20 mhz sine wave input v in = 0.3 v p-p f in2 vcol pin, hf mode, 5 25 mhz sine wave input v in = 0.15 v p-p vcol pin, hf mode, 5 40 mhz sine wave input v in = 0.3 v p-p f in3 vcoh pin, vhf mode, 60 130 mhz sine wave input v in = 0.15 v p-p vcoh pin, vhf mode, 30 250 mhz sine wave input v in = 0.3 v p-p f in4 amifc pin, amif count mode, 0.3 1.0 mhz sine wave input v in = 0.3 v p-p f in5 amifc pin, amif count mode, 0.44 0.46 mhz sine wave input v in = 0.1 v p-p f in6 fmifc pin, fmif count mode, 5 15 mhz sine wave input v in = 0.3 v p-p f in7 fmifc pin, fmif count mode, 10.5 10.9 mhz sine wave input v in = 0.1 v p-p operating frequency f in1 vcol pin, mf mode, 0.50 20 mhz ( pd17p012) sine wave input v in = 0.5 v p-p f in2 vcol pin, hf mode, 5 25 mhz sine wave input v in = 0.15 v p-p vcol pin, hf mode, 5 30 mhz sine wave input v in = 0.3 v p-p f in3 vcoh pin, vhf mode, 60 130 mhz sine wave input v in = 0.15 v p-p vcoh pin, vhf mode, 30 250 mhz sine wave input v in = 0.3 v p-p f in4 amifc pin, amif count mode, 0.3 1.0 mhz sine wave input v in = 0.3 v p-p f in5 amifc pin, amif count mode, 0.44 0.46 mhz sine wave input v in = 0.1 v p-p f in6 fmifc pin, fmif count mode, 5 15 mhz sine wave input v in = 0.3 v p-p f in7 fmifc pin, fmif count mode, 10.5 10.9 mhz sine wave input v in = 0.1 v p-p ad converter characteristics (t a = ?0 to +85 c, v dd = 4.5 to 5.5 v) parameter symbol conditions min. typ. max. unit a/d conversion resolution 6 bit a/d conversion total error 1.0 1.5 lsb
pd17012, 17p012 307 data sheet u10101ej4v0ds reference characteristics (t a = +25 c, v dd = 5.0 v) parameter symbol conditions min. typ. max. unit supply current i dd3 with cpu and pll operating, sine wave input to 12 ma ( pd17012) vcoh pin (f in = 130 mhz, v in = 0.3 v p-p ) i dd4 with cpu and pll operating, sine wave input to 13 ma vcoh pin (f in = 250 mhz, v in = 0.3 v p-p ) supply current i dd3 with cpu and pll operating, sine wave input to 15 ma ( pd17p012) vcoh pin (f in = 130 mhz, v in = 0.3 v p-p ) i dd4 with cpu and pll operating, sine wave input to 16 ma vcoh pin (f in = 250 mhz, v in = 0.3 v p-p ) output current, high i oh3 com 0 to com 2 v oh = v dd ? 1 v ? 300 a output current, low i ol4 com 0 to com 2 v ol = 1 v 300 a output current, i om1 com 0 to com 2 v oh = v dd ? 1 v ? 25 a intermediate i om2 com 0 to com 2 v ol = 1 v 25 a prom programming characteristics ( pd17p012 only) dc programming characteristics (t a = 25 c, v dd = 6.0 0.25 v, v pp = 12.5 0.5 v) parameter symbol conditions min. typ. max. unit input voltage, high v ih1 pins other than clk 0.7v dd v dd v v ih2 clk v dd ?0.5 v dd v input voltage, low v il1 pins other than clk 0 0.2v dd v v il2 clk 0 0.4 v input leakage current i li v in = v il or v ih 10 a output voltage, high v oh i oh = ? ma v dd ?1.0 v output voltage, low v ol i ol = 1.0 ma 1.0 v v dd supply current i dd 30 ma v pp supply current i pp md 0 = v il , md 1 = v ih 30 ma cautions 1. ensure that v pp does not exceed +13.5 v including overshoot. 2. v dd must be applied before v pp , and cut after v pp .
pd17012, 17p012 308 data sheet u10101ej4v0ds ac programming characteristics (t a = 25 c, v dd = 6.0 0.25 v, v pp = 12.5 0.5 v) parameter symbol note 1 conditions min. typ. max. unit address setup time note 2 (to md 0 )t as t as 2 s md 1 setup time (to md 0 )t m1s t oes 2 s data setup time (to md 0 )t ds t ds 2 s address hold time note 2 (from md 0 )t ah t ah 2 s data hold time (from md 0 )t dh t dh 2 s delay time from md 0 to data output float t df t df 0 130 ns v pp setup time (to md 3 )t vps t vps 2 s v dd setup time (to md 3 )t vds t vcs 2 s initial program pulse width t pw t pw 0.95 1.0 1.05 ms additional program pulse width t opw t opw 0.95 21.0 ms md 0 setup time (to md 1 )t m0s t ces 2 s delay time from md0 to data output t dv t dv md 0 = md 1 = v il 1 s md 1 hold time (from md 0 )t m1h t oeh t m1h + t m1r 50 s2 s md 1 recovery time (from md 0 )t m1r t or 2 s program counter reset time t pcr ?0 s clk input high-/low-level widths t xh , t xl 0.125 s clk input frequency f x 4.19 mhz initial mode setting time t i ? s md 3 setup time (to md 1 )t m3s ? s md 3 hold time (from md 1 )t m3h ? s md 3 setup time (to md 0 )t m3sr program memory read 2 s delay time from address note 2 to data output t dad t acc program memory read 2 s hold time from address note 2 to data output t had t oh program memory read 0 130 s md 3 hold time (from md 0 )t m3hr program memory read 2 s delay time from md 3 to data output float t dfr program memory read 2 s reset setup time t res 10 s notes 1. symbol of corresponding pd27c256a (the pd27c256 is a maintenance product). 2. the internal address signal is incremented by 1 on the 3rd fall of a four-clock input (clk) cycle, and is not connected to a pin.
pd17012, 17p012 309 data sheet u10101ej4v0ds program memory write timing program memory read timing v pp v pp v dd gnd v dd + 1 v dd v dd gnd clk d 0 to d 7 md 0 md 1 md 2 md 3 t res t vps t vds t xh t xl t as t ah t dh t ds t opw t df t dv t mos t m1r t dh t ds t pw t i t m3h t m1h t m1s t pcr t m3s data input data output data input data input hi-z data output data output t m3sr t pcr t dv t i t xl t dad t had t vds t vps t xh t m3hr t dfr v pp v pp v dd gnd v dd + 1 v dd v dd gnd clk d 0 to d 7 md 0 md 1 l md 2 md 3 t res
pd17012, 17p012 310 data sheet u10101ej4v0ds 27. package drawings 51 52 32 64 1 20 19 33 64-pin plastic qfp (14x20) note each lead centerline is located within 0.20 mm of its true position (t.p.) at maximum material condition. item millimeters a b d g 23.6 0.4 20.0 0.2 0.20 1.0 i 17.6 0.4 j c 14.0 0.2 h 0.40 0.10 1.0 (t.p.) k 1.8 0.2 l 0.8 0.2 f 1.0 p64gf-100-3b8,3be,3br-4 n p q 0.10 2.7 0.1 0.1 0.1 r s 5 5 3.0 max. m 0.15 + 0.10 ? 0.05 s s n j detail of lead end c d a b r k m l p i s q g f m h
pd17012, 17p012 311 data sheet u10101ej4v0ds 80-pin plastic qfp (14x14) note each lead centerline is located within 0.13 mm of its true position (t.p.) at maximum material condition. item millimeters a b d g 17.20 0.20 14.00 0.20 0.13 0.825 i 17.20 0.20 j c 14.00 0.20 h 0.32 0.06 0.65 (t.p.) k 1.60 0.20 p 1.40 0.10 q 0.125 0.075 l 0.80 0.20 f 0.825 n 0.10 m 0.17 + 0.03 ? 0.07 p80gc-65-8bt-1 s 1.70 max. r3 + 7 ? 3 41 60 40 61 21 80 20 1 s s n j detail of lead end c d a b r k m l p i s q g f m h
pd17012, 17p012 312 data sheet u10101ej4v0ds 28. recommended soldering conditions the pd17012 and 17p012 should be soldered and mounted under the following recommended conditions. for details of the recommended soldering conditions, refer to the document semiconductor device mounting technology manual (c10535e) . for soldering methods and conditions other than those recommended, contact an nec sales representative. table 28-1. surface mounting type soldering conditions (1) pd17012gf-xxx-3be: 64-pin plastic qfp (14 20) pd17p012gf-3be: 64-pin plastic qfp (14 20) soldering method soldering conditions recommended condition symbol infrared reflow package peak temperature: 235 c, time: 30 seconds max. (at 210 c or higher), ir35-207-2 count: twice or less, exposure limit: 7 days note (after that, prebake at 125 c for 20 hours) vps package peak temperature: 215 c, time: 40 seconds max. (at 200 c or higher), vp15-207-2 count: twice or less, exposure limit: 7 days note (after that, prebake at 125 c for 20 hours) wave soldering soldering bath temperature: 260 c max., time: 10 seconds max., count: once, ws60-207-1 preheating temperature: 120 c max. (package surface temperature), exposure limit: 7 days note (after that, prebake at 125 c for 20 hours) partial heating pin temperature: 300 c max., time: 3 seconds max. (per pin row) ? note after opening the dry pack, store it at 25 c or less and 65% rh or less for the allowable storage period. caution do not use different soldering methods together (except for partial heating). (2) pd17012gc-xxx-8bt: 80-pin plastic qfp (14 14) pd17p012gc-8bt: 80-pin plastic qfp (14 14) soldering method soldering conditions recommended condition symbol infrared reflow package peak temperature: 235 c, time: 30 seconds max. (at 210 c or higher), ir35-00-2 count: twice or less vps package peak temperature: 215 c, time: 40 seconds max. (at 200 c or higher), vp15-00-2 count: twice or less wave soldering soldering bath temperature: 260 c max., time: 10 seconds max., count: once, ws60-00-1 preheating temperature: 120 c max. (package surface temperature) partial heating pin temperature: 300 c max., time: 3 seconds max. (per pin row) ? caution do not use different soldering methods together (except for partial heating).
pd17012, 17p012 313 data sheet u10101ej4v0ds appendix a. notes on connecting crystal resonator when using the system clock oscillator, wire as follows in the area enclosed by the broken lines in the figure below to avoid an adverse effect from wiring capacitance. keep the wiring length as short as possible. do not cross the wiring with the other signal lines. do not route the wiring near a signal line through which a high fluctuating current flows. always make the ground point of the oscillator capacitor the same potential as gnd. do not ground the capacitor to a ground pattern through which a high current flows. do not fetch signals from the oscillator. also caution is required for the following three points when connecting the capacitor and adjusting the operating frequency. <1> if capacitances c1 and c2 are too high, the oscillation startup characteristic may be degraded or the current consumption may rise. <2> the trimmer capacitor for adjusting the oscillation frequency is generally connected to the x in pin. however, depending on the crystal resonator used, the oscillation stabilization may be affected (in this case, connect the trimmer capacitor to the x out pin). therefore, oscillation should be evaluated by the crystal resonator that is actually being used. <3> adjust the oscillation frequency while measuring the lcd drive waveform (83.3 hz) or vco oscillation frequency. if the probe is connected to the x out or x in pin, the oscillation frequency cannot be measured correctly due to the probe capacitance. x out x in 4.5 mhz crystal resonator c1 c2 pd17012, 17p012
pd17012, 17p012 314 data sheet u10101ej4v0ds appendix b. development tools the following development tools are available for program development of the pd17012 and 17p012. hardware name description in-circuit emulator ie-17k and ie-17k-et are in-circuit emulators that can be commonly used with any model ie-17k, in 17k series. ie-17k and ie-17k-et are connected to a host machine, which is a pc-9800 series ie-17k-et note 1 or ibm pc/at tm , with rs232-c. when these in-circuit emulators are used in combination with the system evaluation board (se board) dedicated to each model, they operate as emulators corresponding to that model. when human interface software simplehost is used, a more sophisticated debugging environment can be created. se board se-17012 is se board for pd17012 and 17p012. this se board can be used alone to evaluate the (se-17012) system (se-17012) or in combination with an in-circuit emulator for debugging. emulation probe ep-17202gf is an emulation probe for the 64-pin plastic qfp (gf-3be type) of the pd17012 and (ep-17202gf) 17p012. the se board and target system are connected when the ep-17202gf is used in combination with the ev-9200g-64 note 2 . emulation probe ep-17k80gc is an emulation probe for the 80-pin plastic qfp (gc-8bt type) of the pd17012 and (ep-17k80gc) 17p012. the se board and target system are connected when the ep-17k80gc is used in combination with the ev-9200gc-80 note 2 . conversion socket ev-9200g-64 is a conversion socket for a 64-pin plastic qfp (gf-3be type). it is used to connect (ev-9200g-64 note 2 ) the ep-17202gf to the target system. conversion socket ev-9200gc-80 is a conversion socket for an 80-pin plastic qfp (gc-8bt type). it is used to connect (ev-9200gc-80 note 2 ) the ep-17k80gc to the target system. prom programmer af-9703, af-9704, af-9705, and af-9706 are prom programmers corresponding to pd17p012. af-9703 note 3 they can program the pd17p012 when connected to program adapters af-9776b and pa- af-9704 note 3 17p012gc. af-9705 note 3 af-9706 note 3 program adapter af-9776b is an adapter for programming the 64-pin plastic qfp (gf-3be type) of the pd17p012. (af-9776b note 3 ) it is used in combination with the af-9703, af9704, af-9705, or af-9706. program adapter pa-17p012gc is an adapter for programming the 80-pin plastic qfp (gc-8bt type) of the pd17p012. (pa-17p012gc) it is used in combination with the af-9703, af9704, af-9705, or af-9706. notes 1. low-cost model: external power supply type 2. one ev-9200g-64 is provided with the ep-17202gf. five ev-9200g-64s are also available as a set. one ev-9200gc-80 is provided with the ep-17k80gc. five ev-9200gc-80s are also available as a set. 3. these are products of ando electric co., ltd. for details, consult ando electric co, ltd. (tel: +81- 3-3733-1166).
pd17012, 17p012 315 data sheet u10101ej4v0ds software name outline host machine os supply order code media pc-9800 series japanese 3.5"2hd saa13ra17k windows tm ibm pc/at- japanese 3.5"2hc sab13ra17k compatible windows english sbb13ra17k windows pc-9800 series japanese 3.5"2hd saa13as17012 windows ibm pc/at- japanese 3.5"2hc sab13as17012 compatible windows english sbb13as17012 windows pc-9800 series japanese 3.5"2hd saa13id17k windows ibm pc/at- japanese 3.5"2hc sab13id17k compatible windows english sbb13id17k windows 17k assembler (ra17k) device file (as17012) support software ( simplehost ) ra17k is an assembler common to the 17k series products. to develop the program of the pd17012, the ra17k is used in combination with the device file. as17012 is a device file for pd17012 and pd17p012. it is used in combination with an assembler common to the 17k series (ra17k). simplehost is software that serves as a human interface on windows for program development using an in-circuit emulator and personal computer.
pd17012, 17p012 316 data sheet u10101ej4v0ds notes for cmos devices 1 precaution against esd for semiconductors note: strong electric field, when exposed to a mos device, can cause destruction of the gate oxide and ultimately degrade the device operation. steps must be taken to stop generation of static electricity as much as possible, and quickly dissipate it once, when it has occurred. environmental control must be adequate. when it is dry, humidifier should be used. it is recommended to avoid using insulators that easily build static electricity. semiconductor devices must be stored and transported in an anti-static container, static shielding bag or conductive material. all test and measurement tools including work bench and floor should be grounded. the operator should be grounded using wrist strap. semiconductor devices must not be touched with bare hands. similar precautions need to be taken for pw boards with semiconductor devices on it. 2 handling of unused input pins for cmos note: no connection for cmos device inputs can be cause of malfunction. if no connection is provided to the input pins, it is possible that an internal input level may be generated due to noise, etc., hence causing malfunction. cmos devices behave differently than bipolar or nmos devices. input levels of cmos devices must be fixed high or low by using a pull-up or pull-down circuitry. each unused pin should be connected to v dd or gnd with a resistor, if it is considered to have a possibility of being an output pin. all handling related to the unused pins must be judged device by device and related specifications governing the devices. 3 status before initialization of mos devices note: power-on does not necessarily define initial status of mos device. production process of mos does not define the initial operation status of the device. immediately after the power source is turned on, the devices with reset function have not yet been initialized. hence, power-on does not guarantee out-pin levels, i/o settings or contents of registers. device is not initialized until the reset signal is received. reset operation must be executed immediately after power-on for devices having reset function.
pd17012, 17p012 317 data sheet u10101ej4v0ds regional information some information contained in this document may vary from country to country. before using any nec product in your application, piease contact the nec office in your country to obtain a list of authorized representatives and distributors. they will verify: ? device availability ? ordering information ? product release schedule ? availability of related technical literature ? development environment specifications (for example, specifications for third-party tools and components, host computers, power plugs, ac supply voltages, and so forth) ? network requirements in addition, trademarks, registered trademarks, export restrictions, and other legal issues may also vary from country to country. nec electronics inc. (u.s.) santa clara, california tel: 408-588-6000 800-366-9782 fax: 408-588-6130 800-729-9288 nec electronics (germany) gmbh duesseldorf, germany tel: 0211-65 03 02 fax: 0211-65 03 490 nec electronics (uk) ltd. milton keynes, uk tel: 01908-691-133 fax: 01908-670-290 nec electronics italiana s.r.l. milano, italy tel: 02-66 75 41 fax: 02-66 75 42 99 nec electronics (germany) gmbh benelux office eindhoven, the netherlands tel: 040-2445845 fax: 040-2444580 nec electronics (france) s.a. velizy-villacoublay, france tel: 01-3067-5800 fax: 01-3067-5899 nec electronics (france) s.a. madrid office madrid, spain tel: 091-504-2787 fax: 091-504-2860 nec electronics (germany) gmbh scandinavia office taeby, sweden tel: 08-63 80 820 fax: 08-63 80 388 nec electronics hong kong ltd. hong kong tel: 2886-9318 fax: 2886-9022/9044 nec electronics hong kong ltd. seoul branch seoul, korea tel: 02-528-0303 fax: 02-528-4411 nec electronics singapore pte. ltd. novena square, singapore tel: 253-8311 fax: 250-3583 nec electronics taiwan ltd. taipei, taiwan tel: 02-2719-2377 fax: 02-2719-5951 nec do brasil s.a. electron devices division guarulhos-sp, brasil tel: 11-6462-6810 fax: 11-6462-6829 j01.2
pd17012, 17p012 simplehost is a trademark of nec corporation. windows is either a registered trademark or a trademark of microsoft corporation in the united states and/or other countries. pc/at is a trademark of international business machines corporation. the export of this product from japan is regulated by the japanese government. to export this product may be prohibited without governmental license, the need for which must be judged by the customer. the export or re-export of this product from a country other than japan may also be prohibited without a license from that country. please call an nec sales representative. m8e 00. 4 the information in this document is current as of june, 2001. the information is subject to change without notice. for actual design-in, refer to the latest publications of nec's data sheets or data books, etc., for the most up-to-date specifications of nec semiconductor products. not all products and/or types are available in every country. please check with an nec sales representative for availability and additional information. no part of this document may be copied or reproduced in any form or by any means without prior written consent of nec. nec assumes no responsibility for any errors that may appear in this document. nec does not assume any liability for infringement of patents, copyrights or other intellectual property rights of third parties by or arising from the use of nec semiconductor products listed in this document or any other liability arising from the use of such products. no license, express, implied or otherwise, is granted under any patents, copyrights or other intellectual property rights of nec or others. descriptions of circuits, software and other related information in this document are provided for illustrative purposes in semiconductor product operation and application examples. the incorporation of these circuits, software and information in the design of customer's equipment shall be done under the full responsibility of customer. nec assumes no responsibility for any losses incurred by customers or third parties arising from the use of these circuits, software and information. while nec endeavours to enhance the quality, reliability and safety of nec semiconductor products, customers agree and acknowledge that the possibility of defects thereof cannot be eliminated entirely. to minimize risks of damage to property or injury (including death) to persons arising from defects in nec semiconductor products, customers must incorporate sufficient safety measures in their design, such as redundancy, fire-containment, and anti-failure features. nec semiconductor products are classified into the following three quality grades: "standard", "special" and "specific". the "specific" quality grade applies only to semiconductor products developed based on a customer-designated "quality assurance program" for a specific application. the recommended applications of a semiconductor product depend on its quality grade, as indicated below. customers must check the quality grade of each semiconductor product before using it in a particular application. "standard": computers, office equipment, communications equipment, test and measurement equipment, audio and visual equipment, home electronic appliances, machine tools, personal electronic equipment and industrial robots "special": transportation equipment (automobiles, trains, ships, etc.), traffic control systems, anti-disaster systems, anti-crime systems, safety equipment and medical equipment (not specifically designed for life support) "specific": aircraft, aerospace equipment, submersible repeaters, nuclear reactor control systems, life support systems and medical equipment for life support, etc. the quality grade of nec semiconductor products is "standard" unless otherwise expressly specified in nec's data sheets or data books, etc. if customers wish to use nec semiconductor products in applications not intended by nec, they must contact an nec sales representative in advance to determine nec's willingness to support a given application. (note) (1) "nec" as used in this statement means nec corporation and also includes its majority-owned subsidiaries. (2) "nec semiconductor products" means any semiconductor product developed or manufactured by or for nec (as defined above). ? ? ? ? ? ?


▲Up To Search▲   

 
Price & Availability of UPD17012GF-053-3BE

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X